web-dev-qa-db-ja.com

com.Android.builder.dexing.DexArchiveMergerException:dexアーカイブのマージ中にエラーが発生しました:

プロジェクトをコンパイルできません。シナリオでは、Android Studioの "Convert Java File to Kotlin File"を使用して、アクティビティの1つをkotlinに変換し、コードのすべてのエラーを修正しました。それは適切に変換されませんでした。

Javaコンパイラログ:

原因:Java.lang.RuntimeException:com.Android.builder.dexing.DexArchiveMergerException:dexアーカイブのマージ中にエラーが発生しました:


com.Android.builder.dexing.DexArchiveMergerException:dexアーカイブのマージ中にエラーが発生しました:



com.Android.tools.r8.CompilationFailedException:コンパイルを完了できませんでした



com.Android.tools.r8.utils.AbortException:エラー:null、要求されたクラスを単一のdexファイルに収めることができません(#メソッド:110666> 65536;#フィールド:67264> 65536)


build.gradle(アプリ)

apply plugin: 'com.Android.application'

apply plugin: 'kotlin-Android'

apply plugin: 'kotlin-Android-extensions'

apply plugin: 'io.fabric'

Android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"

    defaultConfig {
        versionName "2.2.4"
        versionCode 13

        minSdkVersion 16
        targetSdkVersion 27

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix ".d.5"
        }

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
        }
    }

    flavorDimensions "server"

    productFlavors {
        prod {
            applicationId "com.test.test"
            dimension "server"

            buildConfigField "String", "SERVER_Host", "\"http://www.test.com\""
        }

        dev {
            applicationId "dev.test.test"
            versionNameSuffix ".dev"
            dimension "server"

            buildConfigField "String", "SERVER_Host", "\"http://localhost/test\""
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
        exclude group: 'com.Android.support', module: 'support-annotations'
    })
    implementation('com.crashlytics.sdk.Android:crashlytics:2.7.1@aar') {
        transitive = true
    }

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.schibstedspain.Android:leku:6.0.0'

    implementation 'com.github.sparklit:adbutler-Android-sdk:1.0'
    implementation 'com.j256.ormlite:ormlite-core:5.0'
    implementation 'com.j256.ormlite:ormlite-Android:5.0'
    implementation 'com.squareup.okhttp:okhttp:2.4.0'
    implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'androidx.cardview:cardview:1.0.0-beta01'
    implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
    implementation 'com.google.Android.material:material:1.0.0-beta01'
    implementation 'androidx.vectordrawable:vectordrawable:1.0.0-beta01'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
    implementation 'com.google.Android.gms:play-services-location:16.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.facebook.fresco:fresco:1.9.0'
    implementation 'com.jakewharton.timber:timber:4.7.0'
    implementation 'com.google.Android.gms:play-services-maps:16.1.0'
    testImplementation 'junit:junit:4.12'
    def nav_version = "1.0.0-alpha09"
    implementation "Android.Arch.navigation:navigation-fragment:$nav_version"
    // use -ktx for Kotlin
    implementation "Android.Arch.navigation:navigation-ui:$nav_version"
    // use -ktx for Kotlin

    implementation 'pub.devrel:easypermissions:1.1.1'
    implementation 'devlight.io:navigationtabbar:1.2.5'
}

configurations.all {
    exclude group: 'com.google.guava', module: 'listenablefuture'
}

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

repositories {
    mavenCentral()
}


build.gradle(プロジェクト)

buildscript {
    ext.kotlin_version = '1.3.11'
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.Android.tools.build:gradle:3.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.27.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url "https://maven.google.com" }
    }
}

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

私の悪い(今修正済み)
これをdefaultConfigのbuild.gradle(アプリ)に追加します

multiDexEnabled true

build.gradle(アプリ)

apply plugin: 'com.Android.application'

apply plugin: 'kotlin-Android'

apply plugin: 'kotlin-Android-extensions'

apply plugin: 'io.fabric'

Android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"

    defaultConfig {
        versionName "2.2.4"
        versionCode 13

        minSdkVersion 16
        targetSdkVersion 27

        multiDexEnabled true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix ".d.5"
        }

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
        }
    }

    flavorDimensions "server"

    productFlavors {
        prod {
            applicationId "com.tfwm.lighting"
            dimension "server"

            buildConfigField "String", "SERVER_Host", "\"http://www.test.com\""
        }

        dev {
            applicationId "dev.tfwm.lighting"
            versionNameSuffix ".dev"
            dimension "server"

            buildConfigField "String", "SERVER_Host", "\"http://localhost/test\""
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
        exclude group: 'com.Android.support', module: 'support-annotations'
    })
    implementation('com.crashlytics.sdk.Android:crashlytics:2.7.1@aar') {
        transitive = true
    }

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.schibstedspain.Android:leku:6.0.0'

    implementation 'com.github.sparklit:adbutler-Android-sdk:1.0'
    implementation 'com.j256.ormlite:ormlite-core:5.0'
    implementation 'com.j256.ormlite:ormlite-Android:5.0'
    implementation 'com.squareup.okhttp:okhttp:2.4.0'
    implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'androidx.cardview:cardview:1.0.0-beta01'
    implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
    implementation 'com.google.Android.material:material:1.0.0-beta01'
    implementation 'androidx.vectordrawable:vectordrawable:1.0.0-beta01'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
    implementation 'com.google.Android.gms:play-services-location:16.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.facebook.fresco:fresco:1.9.0'
    implementation 'com.jakewharton.timber:timber:4.7.0'
    implementation 'com.google.Android.gms:play-services-maps:16.1.0'
    testImplementation 'junit:junit:4.12'
    def nav_version = "1.0.0-alpha09"
    implementation "Android.Arch.navigation:navigation-fragment:$nav_version"
    // use -ktx for Kotlin
    implementation "Android.Arch.navigation:navigation-ui:$nav_version"
    // use -ktx for Kotlin

    implementation 'pub.devrel:easypermissions:1.1.1'
    implementation 'devlight.io:navigationtabbar:1.2.5'
}

configurations.all {
    // this is a workaround for the issue:
    // https://stackoverflow.com/questions/52521302/how-to-solve-program-type-already-present-com-google-common-util-concurrent-lis
    exclude group: 'com.google.guava', module: 'listenablefuture'
}

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

repositories {
    mavenCentral()
}

Java.lang.RuntimeException:com.Android.builder.dexing.DexArchiveMergerException:dexをマージできませんAndroid Studio 3.0 [クローズ]

また、解決策は 必須ではありません もしあなたの minSdkVersion 21以上に設定されています

3
Jayson Garcia