I was working on my app, editing and coding some xml and layouts when suddenly I got an error on my libs folder. It's very weird because I haven't actually modified or changed any base classes or something. Moreover, I just noticed I lost also my R.java file and all of the references are gone.
What possibly can be the problem? I tried to clean+build the project but it didn't work.
Here is a screenshot of my eclipse:
http://i.gyazo.com/959040321d1fd6d00ee0b9a90133aa9c.png
Place the jar in the root folder of your project. Then you can add it to your classpath . (you cannot place a jar and access it using android.R)
You can add the jars to your build path by right clicking on your project->properties and going to Build Path. Then you can add an external jar
Related
I am using SVN in Eclipse. I opened an android project and it shows errors. It says some jar files are missing. Initially I developed this project in ubuntu and now I am opening this in windows. So those jar files are referring from ubuntu file path. I have attached a screen shot as well.
I am using actionbar sherlock library and though I added it correctly it gives that error.(android support v4) , because it is referring from ubuntu file path. How to fix this errors?
Thanks.
You may take these support libraries from appcompat libs folder and copy those into your project libs folder and then Add To Build Path by right click and going to add to build path. This will do the trick. Similarly you can took the neede jar files and copy those into your project
I'm trying to use an external jar file in my Android project, I follwed this step for including it:
I put the jar file in libs.
I configured the build path and now I can see the jar file in the Referenced Libraries section of the project.
I use the import to bring the class that I need inside the program.
But I always get NoClassDefFoundError. This jar already works with a classic java program.
Make sure that the jar is being built with the app. In eclipse,
right click on project --> build path --> configure build path.
Make sure the library is checked in the Order and Export tab.
Since Android SDK 17 there is not even necessary to manually add the jar files to buildpath, because they are added automatically, as stated here. Then I would suggest to:
remove the library from buildpath
clean the project
make sure the jar file is located in a folder called libs (not lib) located in the root folder of your project
refresh the project
run the project
The solution found was recompile the library with the version 6 of java and using the jar fail obtained
I tried everything I found posted on Stack Overflow and yet I'm still getting the annoying NoClassDefFoundException when I try to test on the emulator:
I copied the jar to the "libs" directory of the android project
I added the jar to the build path using Add Jar NOT add external jar
I ticked the jar in the export tab
I even tried to compile the jar once with JDK 1.6; still the same annoying exception. The jar I'm referring to just contains a few entity objects I created for another project, and would like to re-use with my Android project.
By the way, I also tried to add the jar as an external jar, but didn't work either.
You need to add it to the assets/ directory along with adding it to build path in that location for it to work. Do remember to pick the same jar when adding external library.
See this thread
NoClassDefFound Error comes in java, when some class is not available on runtime, while it was available at compile time, please check what is source of this error, you can use following blog to get assistance:
http://javarevisited.blogspot.in/2011/06/noclassdeffounderror-exception-in.html
Do the following ::
Go to the project properties >> Java Build Path add jar file as external jar.
Select order and export option >> select the libraries and jars of the project.
If not working change the order of jar make sure its above android dependencies .
In my project I have added some folders that I want included in my project for source files. But no matter what I do, the source never gets recognized. I tried refreshing, clean up, restarting but nothing works. Here is the project's source folder:
I want the folders integration/android added. This is how it is showing up in Eclipse:
And here is what my build configuration looks like:
I could be wrong, but it looks like you have added them as a folder, but not actually added the folder to your project.
The folder should show up in your src folder in the solution explorer window under your other package.
Try creating the package name in your project, then move all the src files into it.
And when its in the src folder, in its correct package, you dont need to include any extra build paths.
(You can have multiple packages in a single application)
Importing someone elses project that is over 2 years old is almost always problematic. I found the easiest solution just to create a fresh project and add the files manually from the old project.
I'm working on an Android project and i need to import an XML library called XOM. The only way i found was to right click on the project name -> Properties -> Libraries tab -> click on "Add external Jar". But that only references it from it's original path, what happens when i compile the app and move it to my phone? Will the Jar be in there?
Might be a stupid question, sorry if that's the case.
It's fine to do that but what I normally do is create a folder called liband then add Jars from there. I find that makes it easier to see what Jars I have in my application.
The main disadvantage of your original approach is that what if the path to that library externally accidentally changes? then your program will not compile. It's better to have everything in the one place to make things easier.
.apk is nothing but a collection or zipped version of a file. it contains all the resources and compiled java files.
So you need not have to worry about the inclusion of your library files. if you have set proper path to your libraries in eclipse then these will be included in your apk file.
Create a directory called "libs" in your under your root directory. You can do it by,
Right click on the project which is in the Package Explorer window in
Eclipse.
New -> Folder -> give "libs" as the Folder name
Copy your jar file and paste it to in the "libs" folder
Expand the "libs" folder
Right click on your copied jar file -> Build Path -> Add to build
path
That's it