Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 错误:将字节码转换为dex时出错:原因:dex无法分析版本52字节码_Java_Android_Gradle_Dex - Fatal编程技术网

Java 错误:将字节码转换为dex时出错:原因:dex无法分析版本52字节码

Java 错误:将字节码转换为dex时出错:原因:dex无法分析版本52字节码,java,android,gradle,dex,Java,Android,Gradle,Dex,我有一个非常奇怪的错误。我使用android studio 2.3 首先请看我的毕业档案 apply plugin: 'com.android.application' android { compileSdkVersion 28 buildToolsVersion "28.0.2" defaultConfig { applicationId "com.example.name.webrtcwork" minSdkVersion 17

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

首先请看我的毕业档案

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'
}
Project clean and rebuild成功运行,但如果我想运行应用程序,我会遇到如下错误

错误:将字节码转换为索引时出错: 原因:Dex无法解析版本52字节代码。 这是由使用Java8或更高版本编译的库依赖项引起的。 如果您在库子模块中使用“java”gradle插件,请添加 targetCompatibility='1.7' sourceCompatibility='1.7' 到该子模块的build.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'
}
错误:1个错误;流产

错误:任务“:app:transformClassesWithDexForDebug”的执行失败。 com.android.build.api.transform.TransformException:java.lang.RuntimeException:java.lang.RuntimeException:无法将“/Users/Hayk.Mkrtchyan/.android/build cache/7fd66238e8a360302161a82746a2b9f0a8b83132/output/jars/classes.jar”预索引到“/Users/Hayk.Mkrtchyan/Desktop/webrtchwork/app/build/intermediates/pre-dexed/debug/classes_547e5465c50bca12a58d5755bafa9d6a10538b52.jar”

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

我不想添加版本1.8,也不想将我的android studio版本升级到3.0。我怎样才能解决这个问题

如果我添加版本1.8并启用jack,它也会给出类似的错误

错误:任务执行失败:应用程序:transformClassesWithPreJackPackagedLibrariesForDebug'。 无法从生成工具加载Jill

我怎样才能解决这个问题

错误:将字节码转换为dex时出错:原因:dex无法分析 版本52字节代码。这是由具有 已使用Java8或更高版本编译。如果您正在使用“java” 库子模块中的gradle插件添加targetCompatibility='1.7' sourceCompatibility='1.7'到该子模块的build.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'
}
FYI

  • 所有
    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
  }
}

阅读。

谢谢大家的回答。问题是这个库(
compile'com.myhexaville:smart-image-picker:1.0.4'
)产生了冲突。当我删除它时,一切终于都正常了。

正如我已经说过的,在添加这行代码并启用jack之后,我得到了如下错误>错误:任务执行失败:app:transformclasses with prejackpackagedlibrariesfordebug'。无法从生成工具加载吉尔。如果我不想将版本更改为1.8,该怎么办?@namesername read@namesername update以支持
com.android。支持:
v28谢谢您的帮助)(祝您好运)