jjzjj

android - 应用程序 :transformDexArchiveWithExternalLibsDexMergerForDebug in Android studio 3. 0.1

coder 2023-12-05 原文

消息 Gradle 构建:

错误:任务“:app:transformDexArchiveWithExternalLibsDexMergerForDebug”执行失败。

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

这里是 gradle 构建文件:

apply plugin: 'com.android.application'

    android {

        compileSdkVersion 26
        defaultConfig {

            minSdkVersion 26
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true

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

    dependencies {

        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso 
        core:3.0.1'
        implementation files('libs/bsh-core-2.0b4.jar')
        implementation files('libs/selenium-java-2.3.0.jar')
        implementation files('libs/selenium-remote-driver-3.0.0.jar')
        // https://mvnrepository.com/artifact/io.appium/java-client
        implementation  group: 'io.appium', name: 'java-client', version: '5.0.4'

    }

最佳答案

这个错误是一般性的,可能是由很多事情引起的

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

首先,你需要知道你有什么错误。因此,您有两个选择:

  • CMD: 转到 android 工作区并放置 gradlew installDebug --stacktrace(可选 --info --debug)
  • 运行或构建项目:转到"file">“设置”>“构建、执行、部署”>“编译器”并在命令行选项中写入:--stacktrace --debug

接下来,您需要进入“原因”部分(最后一个,因为您可能有多个错误)。

如果你有:

Caused by: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

然后你需要把这个,就像之前说的评论一样,但是如果你的 mindSdkVersion >= 21

android {
    defaultConfig 
    {
        multiDexEnabled true
    }
}

如果你的 minSdkVersion < 21="">

compile 'com.android.support:multidex:1.0.3'

更多信息 here

关于android - 应用程序 :transformDexArchiveWithExternalLibsDexMergerForDebug in Android studio 3. 0.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49254785/

有关android - 应用程序 :transformDexArchiveWithExternalLibsDexMergerForDebug in Android studio 3. 0.1的更多相关文章

随机推荐