2

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.

asked Jun 9, 2011 at 16:16
2
  • Can you post some code for us to look at? It's impossible to guess these things. Commented 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. Commented Jun 9, 2011 at 18:02

5 Answers 5

2

if this class is an activity, then make sure you add it to your AndroidManifest.xml file!

answered Jun 9, 2011 at 16:19
Sign up to request clarification or add additional context in comments.

1 Comment

The class is not an activity. It is a part of the google-api-client libraries. Specifically it is: com.google.api.client.xml.XmlNamespaceDictionary;
2

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.

answered May 24, 2012 at 19:49

Comments

1

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.

answered Jul 30, 2020 at 22:58

Comments

0

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

answered Jun 9, 2011 at 16:22

1 Comment

I am not using proguard. I am new to android. To enable proguard you have to specify in your default.properties file, correct? I do not have an entry for progaurd there.
0

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

answered Jun 10, 2011 at 1:01

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.