在Android API 28更新后,出现了“合并dex归档时出错”的错误。

3

我想将我的Android应用移植到API 28(Android 9/P)。

我遇到了5个错误,但我无法解决。我在Android开发方面还比较新手,我认为我的更新方法可能不是最好的。

我已经尝试过清理和重建,但问题仍然存在。

这是我的项目gradle:

buildscript {
    ext.kotlin_version = '1.2.61'

    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.google.gms:google-services:4.1.0'
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'io.realm:realm-gradle-plugin:5.4.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的应用程序 gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'

android {

    lintOptions {
        checkReleaseBuilds false
    }

    compileSdkVersion 28
    defaultConfig {
        applicationId "org.siku.siku"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 118
        versionName "1.0.3"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

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

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude module: 'support-annotations'
    })

    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.android.material:material:1.0.0-rc01'
    implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
    implementation 'androidx.legacy:legacy-support-core-ui:1.0.0-rc01'
    implementation 'androidx.core:core-ktx:1.0.0-rc01'
    implementation 'androidx.exifinterface:exifinterface:1.0.0-rc01'
    implementation 'androidx.vectordrawable:vectordrawable:1.0.0-rc01'
    implementation 'androidx.cardview:cardview:1.0.0-rc01'
    implementation 'androidx.browser:browser:1.0.0-rc01'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.amitshekhar.android:android-networking:1.0.2'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'joda-time:joda-time:2.9.9'
    implementation 'info.hoang8f:android-segmented:1.0.6'
    implementation 'io.nlopez.smartlocation:library:3.3.3'
    implementation 'com.facebook.android:facebook-android-sdk:4.35.0'
    implementation files('libs/CircleImageView-master/gradle/wrapper/gradle-wrapper.jar')
    implementation 'org.greenrobot:eventbus:3.1.1'
    testImplementation 'org.mockito:mockito-core:2.8.9'
    testImplementation 'junit:junit:4.12'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
}

apply plugin: 'com.google.gms.google-services'

repositories {
    mavenCentral()
    google()
}

我遇到了5个错误:

1- 程序类型已存在:android.support.customtabs.ICustomTabsCallback

2- 由于 java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

3- 由于 com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

4- 由于 com.android.tools.r8.CompilationFailedException: Compilation failed to complete

5- 由于 com.android.tools.r8.utils.AbortException

我一直在寻找相关文档,如果您有建议或文档链接,我们将不胜感激。


如果您解决了这个问题,请告诉我您是如何解决的。 - Dr Mido
1个回答

0
也许你已经忘记了,在你的依赖中添加 implementation 'com.android.support:multidex:1.0.3'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接