java.lang.NoClassDefFoundError on Android sdk and ADT 20 Windows 64 - android

Good morning ppl. I have what it looks like to be a commong problem in android, import jars from libraries. I'm trying to use a library to consume an in house api. I copied the jar into the libs folder on my android project and went to
Properties -> Java Build Path -> Libraries and added the jar. Also, I checked the boxes within the jar name in the Order and Export tab. all I have is the
java.lang.NoClassDefFoundError exception.
I have read almost every post that points to the same answer. Put the jar on libs folder and make the steps listed above. Nothing worked. I'm running the ADT v 20, on the Indigo release on a Win 7 x64. I'm not very skilled on java or java architectures but this is driving me nuts. Anyone has a differente approach to this? I'm missing something?
Thanks in advance

You need to simply drag the jar file into the libs folder and not manually add it. Try deleting the jar file from
Properties -> Java Build Path -> Libraries
clean and rebuild the project.
Explanation:
The process of loading library has been automated and changed from ADT 16 onwards and it is not backward compatible with the older method. You were actually trying to use both the methods of adding library which was adding the library twice and breaking it.

Go on the tab "Order and Export", inside "Properties->Java Build Path" and check the unchecked boxes. It worked here...

Related

"Android Private Libraries" doesn't appear in project

The "Android Private Libraries" item is missing from my project (it doesn't appear in the Project Explorer in Eclipse)...
It appears as though it isn't getting built into the project either, as I'm getting various errors regarding jar files in my "libs" folder...
It does appear in Java Build Path (yet it appears to be empty - no jar files appear under it in the Libraries tab), though, and I did make sure it is checked there.
If it is of any relevance, the project at hand has a lot of Android library project dependencies as well, and in those library projects the jar files under libs/ do appear under Android Private Libraries.
I found the problem - I just recently added a new library project as a dependency, and it had an earlier version of android-support-v4.jar in its Android Private Libraries than the one I was using, so that ended up causing the entire Android Private Libraries folder not to be generated in the end project.
Found this out by looking at the Android Console after trying to build.
May be try the following steps
Check and install Android SDK Build-tools in Android SDK Manager.
Package Explorer -> Right click the project -> Android Tools -> Fix Project Properties.
Project -> Clean
Check this Libraries do not get added to APK anymore after upgrade to ADT 22
Please update question with eclipse screen shot to get more clarity on problem you face :)
check console
you can find android-support-v4.jar in two paths
Go to those path manually and replace the android-support-v4.jar with larger size
thats it!!it works for me:-)
this question is duplicated with Libraries do not get added to APK anymore after upgrade to ADT 22
Firstly, you may need to check out our "Problems" view in eclipse for any useful information there. In my issue, it said that two versions of android-support-v4.jar were found in workspace. this error prevented the importation of private libraries. Issue was fixed after I removed one of the jar file.
I removed android-support-v4.jar from java build path in properties and it worked for me.
Remove the oldest jar file from the libs folder and replace it with the same jar file that's being referenced in the other project. If they both have the same version it should work and you should see your Android Private Libraries folder again.

java.lang.NoClassDefFoundError when using third party library in Android application (Aviary SDK)

This has been driving me absolutely crazy. There's 101 answers to this kind of problem scattered across Stack Overflow but nothing seems to work for me.
Here's the story:
I downloaded the Aviary SDK (if that's relevant) and imported their library project into my workspace
I added their Library under Project -> Android -> Add.. and it's checked off there
The JAR (aviary-sdk.jar) containing the class that apparently is missing at runtime (com.aviary.android.feather.FeatherActivity) is listened under Android Dependencies in Project -> Java Build Path
The project builds correctly, but at runtime it throws a java.lang.NoClassDefFoundError when trying to launch this activity
I've tried a bunch of things (checking and unchecking things in Order and Export, reordering things there, etc.) but nothing is taking. I also tried just manually including the JAR in the /libs folder, but this SDK depends on a bunch of other things in that library project (e.g. themes) and having the SDK referenced twice doesn't work either.
I'm completely stumped here. I've looked at all kinds of other answers and nothing seems to work. I'm starting to get the feeling that this method of referencing other libraries is no longer supported...?
Edit: I've created a fresh Android project and reproduced the problem there, too. I suspect it has to be something stupid in my build environment:
Have you tried importing the aviary-sdk.jar as an external jar?
Copy the aviary-sdk.jar into the libs folder on your project
Right click on your project, Build Path -> Add External Libraries
Add the aviary-sdk.jar from your libs folder inside your project
Hope this helps, Good luck ^^
Try a few things,
Number 1: Regarding conflicting jars, it's probably refering to the support library. So go ahead and right click on your library project, and select the option 'Add Support Library'. This downloads the most recent support library, then do the same for your own application project.
The problem is that the library may be using a different support.jar than yours.
Number 2: If that doesn't fix the issue, go to your project properties, Java Build Path, and select 'Order and Export', and make sure that both 'Android Private Libraries' and 'Android Dependencies' are checked.
Clean the project, and try running again.
Figured it out.
After trying everything in the settings, I decided it was the IDEs fault. I deleted my ADT and started a new one, new workspace, imported all my projects (as-is), and launched from there. Everything works.
I guess this is my punishment for always complaining about how Vim was better than any IDE... Ya got me, Eclipse.
disgruntled sigh

Android Eclipse NoClassDefFoundError for external .jar files

I have come across a strange error. I have an Android project that uses external libraries, in particular:
android-support-v4.jar (for Fragment support in Android 1.6)
GoogleAdMobAdsSdk-4.3.1.jar (for ads)
The project ran fine until I updated some aspects of the plugin (can't recall the specifics as I did not pay too much attention to it) and after that, whenever I try to use any class from the above .jar files (or any of its subclasses, even ones defined by me), I would get a java.lang.NoClassDefFoundError. I could not find the answer after much searching, so I am really stumped.
I believe this problem is related to how my IDE is set up and it has little to do with actual code, so I will not post any unless if it's absolutely necessary.
You need to read this - Dealing with dependencies in Android projects.
This link is also useful - ClassDefNotFoundError with ADT 17
Basically, create a folder called libs and place all of your jar files inside. The recent update will automatically take care of the rest for you. You don't need to edit your path anymore.
Android does not support Java1.7 up to now. Jars built with compliance level 1.7 cannot be used in Android Applications. Rebuild your Java project with compliance level 5.0 or 6.0 before exporting the jar file.
I found this post via google and answers above didn't solve my problem. Hope what I say will be helpful to others.
If you see NoClassDefFoundError after upgrading to ADT 22, try this in Eclipse:
Go to Project Properties → Java Build Path → Order and Export tab.
Check the Android Private Libraries option.
Also a warning to others who have updated to r17 with many dependencies. I had a another referenced project on my build path and it still did not work after following ALL the directions on this r17 issue on the internet.
Found out after an hour that my referenced project used an older version of an external Jar than my main project did. When trying to compile the main project, Eclipse would give up due to this jar version difference and I never noticed the warning message in Console.
Solution was to copy the newer version external jar file to the referenced project's libs directory.
Wow - such a productivity killer.....
I ran into this error today too, because of updating to the Android SDK, r17. What the links that #aneal pointed out do not discuss is how to handle external runtime libraries (such as those imported under their own heading - not an imported user library).
The easiest way to solve this problem is to change the build order in the build path. Simply right click on your project and select Properties. From here, select Java Build Path. At the top of the display, choose the tab order and export and move GoogleAdMobAdsSdk-4.3.1.jar above Android X (replacing x with the version you are using). Next, clean your project and run it. You should be good to go!
The way I solved it was by : Right clicking on the project and selecting build path. Select configure build path in the selections that appear. After that see if your libraries are there in the libraries folder and then select the order and export tab and over there select all your jar files. Then select ok and run your project.
If you're using Eclipse with Maven IDE (m2e) go to "Java Build Path" then "Order and Export" and finally check the item "Maven Dependencies" and pull it down to the BOTTOM of the list. You should do the same with project references in the same workspace.
Every time I setup the project in a new computer that happens.

Unable to Debug Library Projects with ADT v14 - Source Not Found

Ever since upgrading my current projects to use the new R14 Tools in Eclipse, I'm now unable to debug any code that exists in my library projects.
When I hit a break point in my library project code, instead of Eclipse opening the original source file, it opens up the read-only copy of the source file contained within the JAR with the message "Source not found".
I've searched around for a solution to this, but have yet to come across anything. Does anybody else have any suggestions? It's quite a pain not being able to debug.
EDIT
The issue has came back and I'm no longer able to debug. I haven't changed any project settings around or anything. Very frustrating.
Tried all of the above and it did not work for me, however the workaround detailed here did.
http://code.google.com/p/android/issues/detail?id=20731
Start debugging, and run until you hit a breakpoint (and precisely get a .class file instead of the .java you would like to have)
Right click in the Debug view of the Debug perspective (for example on the call stack), and choose "Edit Source Lookup Path"
Add all your projects above "Default", via "Add..." > "Java project" > "Select All"
(I'm using ADT 15.0.2 preview from http://tools.android.com/download)
After having this issue as well and doing a little research, I came across this thread and another one that tipped me off. I was pulling my hair out already.
It turns out that the problem is with the build order of your projects (mine was anyway). Since ADT/SDK v14 changed the way library projects are referenced, the build order needs to be correct. Make sure all of the libraries your app uses are built first. I just moved the "src" and "gen" folders for each of my projects to the bottom and now it builds the library first and I am able to debug it and view the source of my library files through the main project.
In case someone doesn't know where to do this, in Eclipse, right click on your project and "Build Path" and then click "Configure Build Path". Then, on the "Order and Export" tab, move the two folders for your project to the bottom of the list below your libraries. I did this for all of my projects and the library projects.
You can also do it globally in Eclipse from Windows->Preferences->General->Workspace->Build Order and moving your library projects to the top. I think the build order defined in each project will override this though, so you may want to do it in both places to solve the issue now and for future projects.
I had the same problem in a project today. The project consists of an app which has two library dependencies. I could not see code during debugging and when using auto-completion when overriding methods Eclipse was unable to deduce proper argument names.
First of all, the problem manifested itself by showing the the 'gen' folder was used as the one that contained the source. To check whether this is the same issue go to your app project, open the Android dependencies and have a look at the properties of the your library dependencies. Location path said /libraryprojectname/gen.
If this is also your problem then go to the 'Order and Export' tab of each library project and move the 'gen' item below the 'src' item. As soon as you click OK Eclipse will work a bit and when you check the Android dependency properties the location path should say: /libraryprojectname/src. Open click the dependency and open any class inside the jar. It should show the source.
I am using ADT plugin 20.0.3 with Android SDK Tools 20.0.3 and Android SDK Platform Tools 14.
The following worked for me on Eclipse Juno:
In Project Properties/Java Build Path:
In the Projects tab, added my library projects.
In the Order and Export tab, moved my library projects to the top, and checked them
Not sure if it's relevant, but Android SDK tools is rev 20.0.3 and Android SDK platform tools is 14.
I assume you are opeining library project and there you put brakepoint.
Try this: On main project open Library Projects->[yourlibrary.jar]->[yourfile.class] from Package Explorer, and then in .class file put brakepoints.
This works for me at least :)
Sometimes this happens to me. Not sure about the reason but the way I solve is:
Remove the main project from eclipse. -- Closs Eclipse -- Delete the jar file in the library project -- Open Eclipse -- Wait for the library project to compile -- Import the main project
This problem also occurs with release 21 of ADT inside Juno. As a workaround, in the "debug" view of the debug perspective (where you see threads and method invocation traces), right click and edit source lookup path.

Cannot build library dependent project after update to ADT 14

In order to implement different versions of our UI we broke our program up into UI specific code and a common library project that has everything else. Up until yesterday when I updated to ADT 14 everything was working fine. Now I can't build. I keep getting the error "The container 'Library Projects' references non existing library 'path to the bin folder of my common project and the name of the project.jar'
I've been all over the web and tried everything I can think of to fix this to no avail. Can someone help me out? I'm basically stuck at this point.
Maybe you have the same issues I had when switching to the new ADT:
In my previous setup I had some resources split between the library and the main project. The library project would not compile error free on its own but only in combination with the main project which added the missing resources.
It doesn't work like this any more.
The library project must compile completely error free now. When it does the build process will create a <lib_project_name>.jar in the bin folder of the library project.
If the jar file is not created ( thus the build process of the library project failed for some reason - eg. because the changes in the R.java file (see http://tools.android.com/recent/buildchangesinrevision14 )) you will get the error message you described.
Also, I had to manually remove the <lib_project>_src from the project.
I've had a problem with a few different projects where I did the fixes suggested in the other answer, but they were only fixed temporarily.
Every time I reopened Eclipse or did a Clean on a project, the "Library Projects" directory would disappear, and I would have to open the project properties, remove the library, and add it again.
I solved this the hard way by creating a new project and copying everything into it.
Then I found an easy way to solve it. Right click the project, Refactor-->Rename. You can rename it back afterwards. This fixed it.
Check out the article "Changes to Library Projects in Android SDK Tools, r14" ( http://android-developers.blogspot.com/2011/10/changes-to-library-projects-in-android.html ) on the Android Developers blog.
E.g. #P.Melch: "I had to manually remove the _src from the project" should be done as follows:
To fix the project, you must remove the extraneous source folders with the following steps:
Right click source folder and choose Build Path > Remove from Build
path.
A dialog will pop up. In it, make sure to check “Also unlink the folder from the project” to completely remove the folder.
You have to update the Android SDK in Android SDK Manager
Android SDK Tools Intalled
Android SDK Plataforms Installed
Android SDK Builds Installed

Categories

Resources