Let's get in touch

Weird Runtime Error after upgrading Android Development Tools to version 22

If you upgraded ADT to version 22 you probably experienced a weird runtime exception when trying to run/debug existing Android projects that reference Android library projects or that contains external libraries in the classpath. Most of our existing applications crashed immediately with weird logcat message which said the main activity can not be instantiated?!

The logcat message looked like this:

Weird message, considering this is the main activity of the application, which is declared in the manifest file and there were no changes in the codebase after the ADT upgrade.

After few hours of googling I found out that there are some changes in the way ADT handles private libraries included in an application (the libraries located in libs folder of the application). At first I thought that ADT introduced new classpath container named “Android Private Libraries” but afterwords realized that it is the same container used in version 21 (com.android.ide.eclipse.adt.LIBRARIES) just with a different display name. In previous versions of ADT the same container was displayed under the name “Android Dependencies”.  After the upgrade to ADT v22, Java build path editor shows two android-related classpath containers:

  • Android Private Libraries (com.android.ide.eclipse.adt.LIBRARIES) – As I mentioned before Android Private Libraries is a container that will automatically include all .jar files from /libs folder into the project’s classpath.
  • Android Dependencies (com.android.ide.eclipse.adt.DEPENDENCIES) – This container is responsible for including all .jar files generated from all referenced Android library projects.

In previous versions of ADT both the .jar files from /libs folder and .jar files from referenced Android library projects were included in the same container (com.android.ide.eclipse.adt.LIBRARIES). This is the only change that I can spot in the project configuration after updating to ADT 22 and can not explain why this change causes application crash. But something in build process obviously changed… I can only guess that changes are somehow related to migration to new gradle-based build system.

To make the long story short, a simple change in classpath configuration fixed the problem and that was to mark  “Android Private Libraries” container to be exported. Also, if your project references other Android library projects which reference private libraries, you should edit each project’s classpath the same way.

Leave your comment

We use cookies to help us optimize the website experience. Okay

Learn more about our privacy policy.