I'm learning now the Java language and using Eclipse for that. When I create an "Android application project" I find out that the menu folder is missing in the res folder. Moreover, in the MainActivity.java I get the error "The import android.view.MenuItem is never used" beside the import android.view.MenuItem.
So, if someone knows how to fix it then please post a solution.
When I create an "Android application project" I find out that the menu folder is missing in the res folder
If you want this folder, create it. There are millions of possible resource folders; the Eclipse wizards will not create them all.
Moreover, in the MainActivity.java I get the error "The import android.view.MenuItem is never used" beside the import android.view.MenuItem.
That is no an error. It is a warning, indicating that the code has an import that is not needed. If you are not planning on using that import any time soon, delete that line.
Related
I'm trying to use this library called OpenSimplexNoise, made by GitHub user TheCodingTrain. But I immediately discovered that I couldn't use it.
I did some digging to try to figure this out on my own, and I discovered that the JAR file and the main folder should have the same name (for example, the library file would be named OpenSimplexName and the JAR file would be OpenSimplexNoise.jar), and the folder the JAR file is in should be called "library." Once I fixed these issues, OpenSimplexNoise appeared in the "Import Library" menu in the "Contributed" section. But once I clicked it, a bunch of code appears:
import japplemenubar.*;
import processing.awt.*;
import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.javafx.*;
import processing.opengl.*;
along with the error message:
More than one library is competing for this sketch.
The import japplemenubar points to multiple libraries:
core (C:\Program Files\Processing\processing.3.5.4\core)
OpenSimplexNoise (C:\Users**\Documents\Processing\libraries\OpenSimplexNoise).
Extra libraries need to be removed before this sketch can be used."
I tried removing japplemenubar, but the same issue appeared with processing.awt, so I tried removing that, but it just kept happening with each different import. I tried deleting it all and just typing "import processing.OpenSimplexNoise.*;", but it said "The import processing.OpenSimplesNoise cannot be resolved."
Does this mean that I'm just doing something wrong, or is this library no longer usable?
I recommend watching/following the videos linked in the README and understanding those:
https://youtu.be/pI2gvl9sdtE
https://youtu.be/U0TGZCEWn8g
The tutorials are how to put organize/compile a basic Processing library from scratch, not how to use library itself.
It would've been easier if a distribution zip would have been uploaded, but the point is learn how to generate it.
Downloading the library zip and unzipping in Processing won't work.
You need to:
(install eclipse if you haven't done so already as part of the video tutorial)
clone / download the project on your computer
Import the project into eclipse:
Drag and drop the build.xml file into the Ant panel: (in my view I've got multiple Processing libraries, you might have just OpenSimplexNoise)
Press the green Play Icon to run the build.
Initially I ran into this error:
BUILD FAILED
/Users/George/Documents/eclipse/OpenSimplexNoise-for-Processing/resources/build.xml:107: The following error occurred while executing this line:
/Users/George/Documents/eclipse/OpenSimplexNoise-for-Processing/resources/build.xml:141: /Users/George/Desktop/OpenSimplexNoise-for-Processing/lib does not exist.
Instead of trying to debug/fix the xml file I simply made the folder structure it wanted: a desktop folder named OpenSimplexNoise-for-Processing containing a lib folder.
Smooth sailing after this: BUILD SUCCESSFUL
Part of the ant build is copying the library to Documents/Processing/libraries so you can simply run the examples from there:
FWIW I've uploaded the compiled library here.
If simply wanted to use noise in Processing the built-in noise() function would do the trick.
If you want Simplex Noise without compiling Daniel Shiffman's example library you could try toxiclibs and it's toxi.math.noise package (also comes with an example sketch).
In the 'lib' directory of my Eclipse project, I have a jar file, 'foo.jar' which contains a class file 'Foo.class' in the (default package) of 'foo.jar', which I have added to my build path in Eclipse (using Project->Properties->Java Build Path->Libraries->Add JARs...). Now, 'foo.jar' appears under the 'Referenced Libraries' section in Eclipse's Package Explorer.
In the 'src' directory of my project I've got a file 'bar.java' whose first line is:
import foo.Foo;
In the body of 'bar.java', the code can use the contents of 'Foo.class' and all appears well, except I get exactly one error, on the import statement: "The import foo cannot be resolved", so the program won't run; it's the only error in 'bar.java'.
What's the proper way to take care of this?
(I have cleaned the project and refreshed it.)
import xxx.Foo; where xxx is the package name, not the name of the jar
If it's the default package, just try using Foo? You won't need the import in that case.
Thanks m8 ;)
I've got a problem with Eclipse. I use the ADT to develop Android apps directly in Eclipse. But right after creating a new project, I got an error in my "MainActivity.java"-file.
I googled and everywhere its said that I have to import an ".R" class from my project folder, which didnt work for me. I also completetely redownloaded Eclipse+ADT in one package this morning.
The line which gives the error is the following:
setContentView(R.layout.main);
Without the "import com.example.myapp.R" statement I've got the same error. Cleaning and rebuilding also didnt have any effect.
Do you have any ideas?
Thanks!
Try to type R r; in your code. Hover your mouse over the 'R' and Eclipse will say "R cannot be resolved to a type". Click import R (com.example.myapp). If this doesn't work then check for the folder gen to say Generated Java Files. Also check to see if they have the classes inside.
R.layout.main refers to a layout XML file in your "res/layout" directory. This seems like the layout file you are trying to reference is named something else.
.
You just need to make sure that your referencing the correct layout in your onCreate method.
setContentView(R.layout.activity_main);
Post the main.xml. Make sure you import your application's R file and not android.R. Restart eclipse, do a clean up by going to your menu Project-> Clean , refresh and tell us if it is fixed.
I'm new in android, and I want to import the jfftpack to my project in android studio anda i don't know how to import it.
The original code was import ca.uol.aig.realdoublefft and I'don't know where to put the java files. I've tried to put them to a libs folder.
here's the jfftpack source code:
If it's an existing code library, I'd recommend adding a module for it. Probably the easiest way is to use the File menu command to add a new module, let it create a plain Java (non-Android) module for you, remove the sample class it puts into the module, and then copy your files over into it and tweak it. The module wizard will take care of setting up the directories and build files for you, and you can look at it later and see what did.
Without pressing Alt + enter to import the Packages?
There is some steps like
1)File --->Settings --from left pane we find editor---->General--->Auto Import
There
Insert imports on paste as ALL not ask
And put check mark for all the Above three Fields
1)Show import popup
2)Optimize the imports on fly
3)Add unambiguous imports on the fly
Click Apply and ok
Happy Coding......
If you have the sources import them in the src folder. Is the simple thing that you can do.
I suggest you to use the command line rather than Android Studio interface.
If you work on Linux or MacOS, try to copy the package to your working direcotry like:
cp -r PACKAGE_NAME PATH_TO/AndroidStudioProjects/PROJECT_NAME/app/src/main/java/
I am also new and had the same problem. I didn't have the package instruction at the top of the java file package com.example.myapp
Say you're working on a Java project in Eclipse and you're looking at a import statement like:
import com.somefirm.somepackage.AClass;
and the classpath for the project has a million and one .jars on it.
How do you determine where the import is coming from?
Open declaration (F3) on the import line. This will open the Java or Class file that the import resolves to.
Once that files is open, you can right-click on the declared type and choose "Show In->Package Explorer" to see where it is declared.
Alternately, if "Link with Editor" is selected in Package Explorer, the related package/jar will already be open for your inspection.
I like to go to the Navigate menu, Open Type... (or Ctrl-Shift-T is quicker), then type in the class name and see the list of possible jars where it could be coming from. You can also use wildcards in the classname you type if you want to see some similarly-named and sometimes related classes.
Now if it lists more than one jar you'll have to try one the methods (F3 or F4) listed in the other answers here, but this is a quick way to see. Worst case scenario is that you'll have more than one version of the same jar.
And if the class is not found into your IDE you can use this resource to find classes in jars.
http://www.jarfinder.com/
if you select the name AClass and hit F4 which will bring up the class hierarchy, and the jar name will be on the status bar.
Right-click on the import line and click on Shown In -> Package Explorer.
You can also right-click on the import line and click on Show in Breadcrumb if you just want to see the path.