Android ADT 21.0.1 java.lang.NoClassDefFoundError R$dimen

Another ADT update breaks my code... this time in a x.x.1 release. After upgrading to ADT 20.0.1 and the related SDK updates, every app tried on a device or emulator was failing to launch with this cryptic error: java.lang.NoClassDefFoundError: ... R$dimen Unfortunately, Eclipse wasn't providing much help as the builds appeared to succeed and happily uploaded the apk only to crash on launch.

After some research, the issue appears to be related to one of the items in the release notes:

Updated build to detect and handle package name conflicts between an application and the libraries it depends on. Libraries cannot share package names unless all of them share the same package name. (Issue 40152, Issue 40273)

Having given up on Eclipse providing a clue (no errors or warnings of any kind that I could spot), I dropped to the command line and ran a manual ant build which resulted in a very helpful build failure error:

android-sdk-linux_x86/tools/ant/build.xml:688: The following packages have been found to be used by two or more libraries:
No libraries must share the same package, unless all libraries share the same packages.

Now just to make things a little more interesting, the com.xxx.yyy package didn't really have anything to do with my library code, but rather my library resources. I have multiple libraries with Android resources and each library Manifest.xml was dumping these resources into com.xxx.yyy which had been working without issue for a couple of years. So the fix is to make sure these resources get dumped into unique packages.

Fortunately, the error led me to zero in on the release note item above and now I know what needs to be done. But it would have been nice if Eclipse/ADT could have told me this and saved some time.

Shop at Amazon and support this site

Copyright © 2006-2013 Quantoa LLC.
All rights reserved.