問題描述
我已經知道這個問題已經被經常問到并得到了答案,但我找到的答案都沒有解決我的問題.
I already know that question has been already asked very often and answers, but no one of the answers i found fixed my problem.
這是錯誤:
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
錯誤是bad class file magic (cafebabe) or version (0034.0000)
.
我在同一天多次構建和執行應用程序而沒有問題,但現在每次都失敗并顯示此消息.
I builded and execute the application without problems many times in the same day but now this fails everytime with this message.
項目SDK為Android API 19 Platform
,項目級別為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'
.
編譯選項:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
在 dependencies
我有:
compile files('libs/bananaquery.jar')
<小時>
該庫是使用 SDK Android API 19 Platform
構建的,項目級別為 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,可能是這個原因?使用 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"
編譯文件可能沒用,因為我也有 compile fileTree(dir: 'libs', include: ['*.jar'])
推薦答案
好吧,我的錯.
在項目 SDK 部分,當您添加 Android SDK
時,您應該提供 Java SDK
并且我的所有 Android SDK 都使用 Java 8作為SDK,即使項目級別是1.7
,它也會創建具有錯誤版本的類文件(我不知道為什么,我認為一切都是由項目級別選擇的).
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).
現在我更改了 SDK(java 版本1.x.0"
部分.)
Now i changed the SDK (the java version "1.x.0"
part.)
它似乎編譯得很好.
今天之前有效的原因是因為我的 SDK 是 1.8
而不是 Android API x
The reason that worked before today was because my SDK was 1.8
and not Android API x
這篇關于錯誤的類文件魔法或版本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!