gpt4 book ai didi

android - 意外的顶级异常向 Android Studio 项目添加新模块

转载 作者:行者123 更新时间:2023-11-29 00:18:57 25 4
gpt4 key购买 nike

添加一个简单的 Java 库(Android Studio 中的新模块)后出现令人沮丧的错误。我已经阅读了很多类似的问题,但找不到任何解决方案,任何人都可以帮助我吗?

Error:Execution failed for task ':KeepLinkMain:preDexDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\Android\android-sdk\build-tools\19.1.0\dx.bat --dex --output C:...\AndroidStudioProjects\KeepLink\KeepLinkMain\build\intermediates\pre-dexed\debug\KeepLinkLib-d6db361e6605649280566ee9a3143d04322844dc.jar C:...\AndroidStudioProjects\KeepLink\KeepLinkLib\build\libs\KeepLinkLib.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/rmpt/keeplinklib/Constants.class 1 error; aborting

主模块build.gradle文件

    apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
jniDebugBuild false
}
}
dexOptions {
incremental true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
}

dependencies {
compile project(':KeepLinkLib')
compile files('lib/gson-2.2.4.jar')
}

Java 库 build.gradle 文件

apply plugin: 'java'

最佳答案

我遇到了类似的问题,并且能够通过将以下行添加到 Java 库的 build.gradle 中 apply plugin: 行下来解决:

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

我还必须从主模块的 build.gradle 中删除 compileOptions block

关于android - 意外的顶级异常向 Android Studio 项目添加新模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24346985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com