NoClassDefFoundError for libs added in Android Lib Project - android

I have a Android Lib Project which has a number of libraries (jars) added in /lib folder.
Now, I have written a Android Test Project to test the APIs of the Library project and I added the jar of the Lib project inside this test project.
Everything complies fine but when the code, in the Library project executes, which uses the jar file, I am getting a NoClassDefFoundError.
Could someone please help me with this issue?
Please do let me know what other details would be required from my end.
Thanks

Try to Clean Project and Run it again.

Try this way,
Right click on your project --> select Build Path --> go to Order and Export Tab
Check all the libs you added here and done.

Related

Project library not getting added to android project

Iam trying to reference a Android project library to my application. I do this:-
1)File->Import->General->Existing project into workspace->Select project library->check copy to workspace.
2)Right click on project->Properties->Android-> Add-> Select project library-> Apply-> ok.
But when I again check if the library is added I get the following:-
How do I resolve this?
Make sure that your library has the same location with your project source files.
It means that if your source is on your workspace , then your library should add into workspace. If not, you should copy your lib into same folder with source then mount it again.
Make sure the library project is checked as a library.
Go to the library projects BuildConfig -> Android -> Check "is library"
Make sure your project and the library project have the same target/min SDK versions.
It's also a good idea to clean your workspace and Build the library project - Right click on library project -> "Build Project"
Try this answer:
The project name needs match the folder name on the file system. What you are seeing in the Project Properties->Android->Library Reference is a relative file system path.
Reference:
In eclipse, unable to reference an android library project in another android project
Thanks to archie-bpgc for comment
i am also facing this problem i have solve this problem like
when import lib in to workspace tick mark as show in picture (basically library project and your project both are in same workspace)
now add lib to your project and clean project
you need to import the project to workspace and the library file into the same workspace.
Then you will not face this error. Kindly the root cause is not known. But this method works.
After all this .. one more way is you can alter the project properties last line where the library file path is specified.
Thank you.

Referencing Android Library Project Error

I am having issues getting my project that references an Android Library to compile. I have exactly followed the instructions in the documentation here: http://developer.android.com/tools/projects/projects-eclipse.html
My android library is is marked as a library correctly, and I can see the jar file and all my .class files in my project. But the classes are not found when I try to reference them in my new project and it will not compile. What am I doing wrong?
Here is a screenshot (SoundGraphingLibrary is my library project and SoundGraphingLibrary is the project I need to use the library in):
Make sure that the project and the library project are in the same folder..
First, run Project->Clean on the library, then your project as #iagreen suggests. Then go ahead and close and reopen eclipse. Wait for everything to build.
Assuming nothing is better at this point, click on the library and do Project->Properties->Android. Confirm that Is Library is checked. Now, delete any instance of the library *.jar in your project. Do Project->Properties->Android on your project. Click Add... and click on the library you want, OK, Apply, OK.
That should do it. Also, fire lemurs.
Not sure if this helps but i did the following
Remove and adding the library by going to Project->Properties->Android.
Clear the project by going to Project->Clean
Restart Eclipse and tata it works.

Android: Unable to include facebook sdk library project

I am working with Android API 17 on eclipse Indigo. I have cloned the faccebook sdk from github and done the facebook library project set up using the source project provided in the fb sdk.
Now I'm trying to include this library project in my android demo project. I have added it under Project properties->Android->Library section. Im seeing green color tick mark infront of the added library.
Also, i have added the same in the Project properties->Java build path->Projects.
build is successful. but when i try to install on my AVD, im getting the error, E/AndroidRuntime(748): java.lang.NoClassDefFoundError: com.facebook.android.Facebook
Can anybody plz help me how to fix this issue.
---- EDIT ------
One more thing I have observed is, when i opened Project properties->Android window, the green tick mark is not displaying under Library section, instead I'm seeing red cross mark.
Any ideas?
Thanks,
Venkat Papana
Same thing happen for me also.. try below .. it will work..
A Best way to add External Jars to your Android Project or any Java project is:
Create a folder called libs into you project root folder
Copy your Jar files to the libs folder
Now right click on the Jar file and then select Build Path > Add to Build Path, this will create a folder called Refrenced Library into you project, and your are done
By do doing like this, whenever you transfer you project to other Computer, you will not miss your libraries which are being referenced to some space on your Hard drive.
(The facebooksdk.jar can be found at the facebook-sdk directory: <facebook-sdk>\facebook\bin)
i know this question is old But I thought that may be it can help someone.
Move the library project and the application on the same drive. Usually this is a bug in Eclipse.
I solved my problem by moving them in same drive on my computer.
You can Give it a try.
You need to make both project in same dictionary then include it using Project Properties -> Android-> Library.
This works fine.
You do not have to add this to the library project as this is not the library.
https://github.com/facebook/facebook-android-sdk is the help of the project ad the sample code for the including the project in our code. Just you need to create the app ID for the facebook by registering your api with it.
Hope this will help you in your project.
Resolved by copying the com.facebook.android source code to my project source.

How do I build my project with ANT when it depends on a non-library project with an Android library project dependency?

I'm trying to build my project using ANT. My project uses ActionbarSherlock, and Roboguice-Sherlock. ActionbarSherlock is an Android library project, but Roboguice-Sherlock is not. It's not even an Android project at all. See here:
https://github.com/rtyley/roboguice-sherlock
I can get ActionbarSherlock to build using ANT no problem, the problem lies with Roboguice-Sherlock. It's not an Android project, yet it has dependencies on Android and ActionbarSherlock, as well as Roboguice. When I try to build I get a ton of errors saying it can't find the Roboguice-Sherlock stuff.
If your project has the Roboguice .jar and the library project reference to ActionBarSherlock already configured you should be able to just drop it into your libs/ folder to have it automatically picked up.
I am working with Roberto to ensure that the .jar of his project gets uploaded to GitHub for non-Maven users to use.
For now, you can clone the project simply run mvn clean package to get a standalone .jar in the target/ folder which will enable you to do as I described above.
You need to add robiguice-sherlock as a .jar to your Android project. You can download it here (click Download (JAR)). Trying to build the source in Android will fail because it is not an Android project. Once it is in your directory, you need to open project properties and add the .jar to your build path.

VerifyError in android test-project build tools v17

Since installing v17 of the android build tools I am getting a VerifyError in my test project.
A short description of my project structure:
All jar files exist in my main projects libs folder
The test-project is a project that resides inside my main project
All Instrumentation tests exist in the same package as my activities.
I have one jar that is only needed for the test projects in my libs folder in the test project
Has anyone seen this? Its happening on all my projects since updating. Running the test produces an InstrumentationException: java.lang.VerifyError
x...#android.com made a temporary fix for an issue I reported: http://code.google.com/p/android/issues/detail?id=27608.
You can try to see if the new anttasks.jar file can fix your problem.
It fixed mine. NoClassDefFoundError when running Instrumentation test with ant
In my case, I have a test project using the library of "robotium".
I'd had the same problem, and soleved by following steps,
"Properties > Java Build Path > Libraries", delete "Android Dependencies" in my test project.
"Properties > Java Build Path > Libraries", delete two robotium jar and click "Add JARs" to re-import robotium jar in my test project.
"Properties > Java Build Path > Order and Export", check two checkbok of robotium jar (and othera you want exported.)
Clean my test project.
I think you also solve the problem, Good Luck!
more information
How to fix the “NoClassDefFoundError” with ADT 17
Dealing with dependencies in Android projects
in my case, first, add robotium-solo-2.5 in properties->build path->Libraries,and then move robotium-solo-2.5.jar to the top in properties->build path->Order and export, finally i solve this funny problem easily...
“Properties > Java Build Path > Order and Export”, and check all the references you want exported.
The way Android deals with dependencies has recently changed. If you are using eclipse, then just remove your jar imports and place them in a "libs"-folder in the project root, and everything will be imported automatically.

Categories

Resources