Wednesday, May 22, 2013

Android latest SDK: java.lang.ClassNotFoundException

Since the latest Android SDK revision (22) it is possible to get java.lang.ClassNotFoundException or other unexpected errors with Eclipse, for instance when making use of one Android project in another Android project.


An example of failure can also be found when trying to use the Android support library:

05-22 19:49:46.240: E/AndroidRuntime(4094): Caused by: java.lang.NoClassDefFoundError: android.support.v4.app.NotificationCompat$Builder

To fix this, developers must now explicitly export the Android Private Libraries.

Fix:

Open the properties of your Android projects (even the ones that are included by other projects), select Java Build Path, Order and Export, and finally check Android Private Libraries.