I am getting a classdefnotfound error at runtime for my Android app. Everything runs fine except this one class. Previously this class worked. The class is actually in an external library and all libraries are correct. Has anyone run across any thing like this in eclipse? I feel like it is an environment problem.
The class is in google api client library version 1.4.1.
classdefnotfound: com.google.api.client.xml.XmlNamespaceDictionary;
The jar file is in the lib directory and in the .classpath file.
-
Can you post some code for us to look at? It's impossible to guess these things.Phonon– Phonon2011年06月09日 16:18:56 +00:00Commented Jun 9, 2011 at 16:18
-
UPDATE: I have compiled the code with the error in a separate sample app and it ran fine. The same exact code crashes in the other project. I have the exact same libraries include in both projects. I am at a loss here. Considering reinstalling eclipse as I have run out of options.Patrick Jackson– Patrick Jackson2011年06月09日 18:02:28 +00:00Commented Jun 9, 2011 at 18:02
5 Answers 5
if this class is an activity, then make sure you add it to your AndroidManifest.xml file!
1 Comment
I encountered this problem quite unexpectedly, and couldn't really fix it with proposed solutions. As it turned out, this blog post was very helpful. In short, I had all my libraries in lib folder instead of libs, and added them to Eclipse's build path. But in the latter case, Android automatically adds your libraries. Renaming the folder to libs and removing previous manual changes to the classpath fixed the problem.
Comments
From what I've noticed this error is usually caused by a ClassNotFoundException and in my case this exception was thrown because I had implemented interfaces which were not yet introduced during the time of release of the version of the android OS on which the app was running...this apparently caused the class to not be recognized at runtime.
Comments
Sometimes this happens when you export your project and use obfuscation. Proguard will erase classes that are only mentionned in the manifest.xml and not used directly in your code (such as introspection class loading).
In that case, you should configure proguard to keep your class, look at proguard.cfg and add a line for your class.
Also, if this happens in debug mode and not for an exported app, then you could unzip your apk file, use dexdump to see if your class is included in your dex file or not.
dexdump comes with the android sdk and can be used to decompile classes.dex in your apk.
Regards,
Stéphane
1 Comment
Ok, I've figured it out(after 8 hours of hair pulling!). The google client lib jar files were located in another project(the one that was working). I had added them to the project as a referenced library. For some reason it was not getting added at compile time. Solution: copied the actual jar files to the /lib directory and update the build path in eclipse by removing the referenced libs
Comments
Explore related questions
See similar questions with these tags.