問題描述
我已經(jīng)知道這個(gè)問題已經(jīng)被經(jīng)常問到并得到了答案,但我找到的答案都沒有解決我的問題.
I already know that question has been already asked very often and answers, but no one of the answers i found fixed my problem.
這是錯(cuò)誤:
Error:Gradle: Execution failed for task ':ffcommunity:preDexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:Android SDKsdkuild-tools20.0.0dx.bat --dex --output D:UsersReVoDocumentsIntelliJ IDEAFFCommunityffcommunityuildintermediatespre-dexeddebugananaquery-2ee85432877a057e7414910b8127805535139d5d.jar D:UsersReVoDocumentsIntelliJ IDEAFFCommunityffcommunitylibsananaquery.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:665)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
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:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
...while parsing com/comuf/revonline/bananaquery/BananaInsert.class
1 error; aborting
錯(cuò)誤是bad class file magic (cafebabe) or version (0034.0000)
.
我在同一天多次構(gòu)建和執(zhí)行應(yīng)用程序而沒有問題,但現(xiàn)在每次都失敗并顯示此消息.
I builded and execute the application without problems many times in the same day but now this fails everytime with this message.
項(xiàng)目SDK為Android API 19 Platform
,項(xiàng)目級(jí)別為1.7
.
Project SDK is Android API 19 Platform
and project level is 1.7
.
CompileSDK 是 19
并且 buildToolsVersion 是 '20.0.0'
.
CompileSDK is 19
and buildToolsVersion is '20.0.0'
.
編譯選項(xiàng):
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
在 dependencies
我有:
compile files('libs/bananaquery.jar')
<小時(shí)>
該庫是使用 SDK Android API 19 Platform
構(gòu)建的,項(xiàng)目級(jí)別為 1.7
.
The library is build with SDK Android API 19 Platform
with project level 1.7
.
我的 .jar
文件位于 libs/
文件夾中.
My .jar
file is inside libs/
folder.
我使用 IntelliJ IDEA 14 Preview,可能是這個(gè)原因?使用 IntellIJ IDEA 13,它仍然停留在Gradle 同步"
I use IntelliJ IDEA 14 Preview, it could be the reason? With IntellIJ IDEA 13 it remains stuck at "Gradle sync"
編譯文件可能沒用,因?yàn)槲乙灿?compile fileTree(dir: 'libs', include: ['*.jar'])
推薦答案
好吧,我的錯(cuò).
在項(xiàng)目 SDK 部分,當(dāng)您添加 Android SDK
時(shí),您應(yīng)該提供 Java SDK
并且我的所有 Android SDK 都使用 Java 8作為SDK,即使項(xiàng)目級(jí)別是1.7
,它也會(huì)創(chuàng)建具有錯(cuò)誤版本的類文件(我不知道為什么,我認(rèn)為一切都是由項(xiàng)目級(jí)別選擇的).
In the Project SDK section, when you add an Android SDK
you should provide the Java SDK
and all my Android SDKs uses Java 8 as SDK so it create the class files with the wrong version even if the Project level is 1.7
(i don't know why, i supposed that everything was choosed by Project level).
現(xiàn)在我更改了 SDK(java 版本1.x.0"
部分.)
Now i changed the SDK (the java version "1.x.0"
part.)
它似乎編譯得很好.
今天之前有效的原因是因?yàn)槲业?SDK 是 1.8
而不是 Android API x
The reason that worked before today was because my SDK was 1.8
and not Android API x
這篇關(guān)于錯(cuò)誤的類文件魔法或版本的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!