Android-SDK r17 ruins working projects

后端 未结 6 1781
醉酒成梦
醉酒成梦 2020-12-07 01:23

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

相关标签:
6条回答
  • 2020-12-07 01:39

    I tripped up over the same error when using the ADT 18. There were several causes, including having to move my jar files from a lib to a libs folder. Coincidentally I was using a new workstation with JDK 7 installed. It took me several hours to fathom out that the dex build step was rejecting the compiled class files from one of the jar files I built separately because the class signature was unacceptable. The error reported by the dex build step was "trouble processing: bad class file magic (cafebabe) or version (0033.0000)"

    My jar file consists of pure Java code which I build using ant. Cutting a long story short, I finally managed to get everything to work once I installed Java 6's JDK, added the path to the JDK 6 bin folder as the first item in my path statement & then rebuilt the jar file. I was then able to use the jar file in my Android project. The dex build step didn't reject the classes from the jar file and therefore my app ran on the device rather than failing with a ClassNotFoundException.

    I discovered several helpful tips: - Run ant with the -v command line option and scrutinize the output carefully. That's how I knew the java6 compiler was being used at the end of all my changes. And similarly when I built the Android app using ant, the dex stage had enough detail to tell me which jar files it processed, etc.

    Similarly in Eclipse I enabled the verbose level of logging for the Android build output. Preferences>Android>Build>Build output> Verbose

    adb logcat output actually reports the missing class files when it loads the app. If you're using the LogCat view in Eclipse the relevant lines are in red text and easy to spot once you know they exist.

    I hope this helps others in a similar predicament to one I found myself in - where I created my own pure java jar files. Several factors had changed including the Java SDK version and the ADT tools, and diagnosing the various causes was a challenge.

    0 讨论(0)
  • 2020-12-07 01:40

    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.

    0 讨论(0)
  • 2020-12-07 01:43

    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.

    0 讨论(0)
  • 2020-12-07 01:46

    Sometimes beside closing/re-opening project eclipse restart is necessary to make everything work as planned and expected. Especially if you updated any of component. But of course as CommonsWare mentioned library folder adjustment is mandatory.

    0 讨论(0)
  • 2020-12-07 01:52

    This topic is also being discussed at the android-developers forum. The magic recipe that worked for me was this: In addition to re-homing included libraries, I had to change my target SDK in Project Properties away from 4.0.3 and back again. That fixed it.

    0 讨论(0)
  • 2020-12-07 01:53

    If you are not using Maven here is the detailed guide with pictures, like mentioned from CommonsWare.

    http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17

    But if you are using Maven dependencies are not included with the library project m2e-android connector still does not know how to handle this, so if you have Android projects with Maven don't update to ADT 17.

    The new 0.4.1 version of the Android Connector for M2E (m2e-android) has been released and a bug with Maven projects are fixed. https://github.com/rgladwell/m2e-android/issues/72

    0 讨论(0)
提交回复
热议问题