Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android-SDK r17 ruins working projects

Tags:

android

I have updated my android-sdk-package from r16 to r17. I have updated the Eclipse ADT-Plugin too.
My project worked perfectly fine with r16 (android-sdk r16 and Eclipse ADT Plugin v16), but now the app does not start: The Classloader can not find the MainActivity. The MainActivity is the first activity, that starts (it is properly declared in the AndroidManifest).

03-22 15:07:28.984: E/AndroidRuntime(22106): Caused by: java.lang.ClassNotFoundException: my.....MainActivity
03-22 15:07:28.984: E/AndroidRuntime(22106):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-22 15:07:28.984: E/AndroidRuntime(22106):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-22 15:07:28.984: E/AndroidRuntime(22106):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-22 15:07:28.984: E/AndroidRuntime(22106):    at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
03-22 15:07:28.984: E/AndroidRuntime(22106):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871) 

The package name is 100% right. I even checked out a tagged version of my project (I have release the project and I always tag my versions) and tryed it: same result.
What I have already tried (I use Arch Linux):
- delete android-sdk + android-sdk-platform-tools (and reinstall them)
- delete the entire android-folder (/opt/android-sdk) and reinstall the packages, download the target platform
- delete ~/.android
- delete ~/.eclipse
- reinstall Eclipse ADT-Plugin
- recreate Virtual Devices
- create a new project (the new project works)
- unpack the .apk-file and view the compiled classes with dexdump: the apk-file contains the MainActivity
- I read the Android-SDK-Release-Notes for something related, but I didn't find anything
- And of course, rebuild the project (clean + build, I even manually deleted the bin-folder)

The only thing that really worked was to switch on my notebook (still android-sdk r16).
So... what am I doing wrong? It's probably something simple...

Thanks!

like image 395
Paul S. Avatar asked Mar 22 '12 14:03

Paul S.


2 Answers

As has been reported here and elsewhere, you need to ensure that any third-party JARs you are using live in libs/, both in your project and in any dependent library projects. Try that and see if it helps.

like image 100
CommonsWare Avatar answered Nov 15 '22 21:11

CommonsWare


For those developers using straight Ant builds with a custom build.xml which has overridden targets which refer to "jar.libs.ref", you should note that this has been replaced, so your build will fail.

Changing this to "project.libraries.jars" worked for my targets, but you should probably check the diffs between the previous sdk/tools/ant/build.xml and the new one. It's always worth taking a copy of this before you upgrade the SDK tools, as the Ant builds quite often get broken by the upgrade process.

like image 21
NickT Avatar answered Nov 15 '22 22:11

NickT