使用gradle编译我的libgdx项目时遇到错误。
Execution failed for task ':android:preDexAmazonDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/SDK-PATH/Android/build-tools/21.0.1/dx --dex --output /PATH/android/build/intermediates/pre-dexed/Amazon/debug/core-1.0-47e2423a0159bad5774996683a8ab834009ab7ed.jar /PATH/core/build/libs/core-1.0.jar
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:82)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:279)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
...while parsing org/mars3142/OwnClass.class
1 error; aborting
我没有将核心两次包含在我的Android项目中。我仔细检查过,如果我包含一些外部库,但似乎我自己的项目是失败的,我无法理解,因为我从未改变过某些东西。我只在我的项目中添加了一个android-wear项目。如果我回到时间(使用git),它也是不可编译的。
编辑:如果我在 IntelliJ 中点击运行获取相同的构建变体(AmazonDebug),它就会像预期的那样工作。这真的很奇怪。