错误的类文件魔法或版本

时间:2023-02-14
本文介绍了错误的类文件魔法或版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经知道这个问题已经被经常问到并得到了答案,但我找到的答案都没有解决我的问题.

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模板网!

上一篇:使用“flatDirs"将本地 .aar 文件添加到 Gradle 构 下一篇:错误:任务':android:transformClassesAndResourcesWithPr

相关文章

最新文章