NoClassDefFoundError on external library project for Android

前端 未结 7 1643
孤独总比滥情好
孤独总比滥情好 2020-11-29 08:24

I use eclipse for Google Android development.

I\'ve created a library project ([x] Is Library in the Android-settings), which includes an external jar-f

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 08:55

    I had a similar problem and non of the solutions out here fixed it.

    Short version: the JAR was compiled in Java 1.7 and could not be found by Dalvik.

    We build an internal JAR that we share across backend and mobile clients with Maven. The problem ended up being that the JAR was compiled with Java 1.7. Androids dalvik only supports Java 1.5 and 1.6. This is why everything works fine in Eclipse as it's not compiled to dalvik at this point.

    We even specified the target and source version in the Maven compiler plugin to compile with Java 1.6. This did not work because only JDK 1.7 was installed on the build machine. A small note at the bottom of the Maven page gave us the hint: Note: Merely setting the target option does not guarantee that your code actually runs on a JRE with the specified version.

    To see if you have this problem as well, rename your *.jar file to *.zip unpack it, and look in the MANIFEST.MF file for the Build-Jdk: parameter to see what Java version actually compiled your JAR.

提交回复
热议问题