gpt4 book ai didi

java - 错误 :Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code

转载 作者:行者123 更新时间:2023-11-29 23:35:06 24 4
gpt4 key购买 nike

我有一个非常奇怪的错误。我使用的是 android studio 2.3。

首先请看我的gradle文件。

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "com.example.name.webrtcwork"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
sourceSets.main {
jniLibs.srcDir 'libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.myhexaville:smart-image-picker:1.0.4'
compile 'pub.devrel:easypermissions:1.1.3'
compile('io.socket:socket.io-client:1.0.0') {
exclude group: 'org.json', module: 'json'
}
compile 'com.android.support.constraint:constraint-layout:1.0.2'

compile files('libs/autobanh.jar')
compile files('libs/base_java.jar')
compile files('libs/libjingle_peerconnection.jar')

testCompile 'junit:junit:4.12'
}

项目清理和重建工作成功,但如果我想运行应用程序,我会收到这样的错误。

Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code. This is caused by library dependencies that have been compiled using Java 8 or above. If you are using the 'java' gradle plugin in a library submodule add targetCompatibility = '1.7' sourceCompatibility = '1.7' to that submodule's build.gradle file.

Error:1 error; aborting

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/Users/Hayk.Mkrtchyan/.android/build-cache/7fd66238e8a360302161a82746a2b9f0a8b83132/output/jars/classes.jar' to '/Users/Hayk.Mkrtchyan/Desktop/WebRTCWork/app/build/intermediates/pre-dexed/debug/classes_547e5465c50bca12a58d5755bafa9d6a10538b52.jar'

好的,我尝试了很多方法来解决问题,例如添加 targetCompatibility = '1.7'
sourceCompatibility = '1.7'
在我的构建文件中。这行不通。

我不想添加 1.8 版本,也不想将我的 android studio 版本升级到 3.0。我该如何解决这个问题?

如果我添加 1.8 版本并启用插孔,它也会给出错误。

Error:Execution failed for task ':app:transformClassesWithPreJackPackagedLibrariesForDebug'. Cannot load Jill from build tools.

我该如何解决这个问题?

最佳答案

Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code. This is caused by library dependencies that have been compiled using Java 8 or above. If you are using the 'java' gradle plugin in a library submodule add targetCompatibility = '1.7' sourceCompatibility = '1.7' to that submodule's build.gradle file.

仅供引用

  • 所有 com.android.support: 版本应该相同。

Android Studio 3.0 及更高版本支持所有 Java 7 语言功能和 Java 8 语言功能的子集,这些功能因平台版本而异。也可以直接在对应的build.gradle文件中配置:

android {
...
// Configure only for each module that uses Java 8
// language features (either in its source code or
// through dependencies).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

阅读Use Java 8 language features .

关于java - 错误 :Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52331167/

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