我在API 19,24,25上启动了我的应用程序,并且运行良好。但是在API 23上,我的应用程序没有启动,在构建阶段崩溃(渐变)。
错误是:

Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Exception parsing classes
(the number of such errors is 28)

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:
java.lang.RuntimeException: com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
Return code 1 for dex process

我的build.gradle:
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "***"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 7
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
    }
}

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:26.+'
    compile 'com.android.support.constraint:constraint-layout:+'
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'
}

如何解决这个问题呢?
对不起,我的英语知识差。

最佳答案

在您的build.gradle-中进行编译:

implementation 'com.android.support:multidex:1.0.0'

关于android - Android,gradle。在API 23上运行应用程序时,将字节码转换为dex时出错。但是我的应用程序可以在其他API上正常运行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48226402/

10-10 17:10
查看更多