Android Studio 3.2.1:transformDexArchiveWithExternalLibsDexMergerForDebug 失败

Posted

技术标签:

【中文标题】Android Studio 3.2.1:transformDexArchiveWithExternalLibsDexMergerForDebug 失败【英文标题】:Android Studio 3.2.1: transformDexArchiveWithExternalLibsDexMergerForDebug FAILED 【发布时间】:2019-05-16 16:45:40 【问题描述】:

我想迁移到 android Studio 3.2.1

我的项目/build.gradle:

buildscript 

    repositories 
        google()
        jcenter()
    
    dependencies 
        classpath 'com.android.tools.build:gradle:3.2.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    

在我的 app/build.gradle 中:

        apply plugin: 'com.android.application'

android 
    compileSdkVersion 28
    defaultConfig 
        applicationId "com.myproject"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 421
        versionName "2.1.421"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

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

    packagingOptions 
        exclude 'META-INF/DEPENDENCIES'
    


// must be version 4.5.2
def AAVersion = '4.5.2'

dependencies 
    annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
    annotationProcessor "org.androidannotations:ormlite:$AAVersion"

    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'org.apache.commons:commons-lang3:3.8.1'
    implementation 'org.apache.httpcomponents:httpclient:4.5.6'
    implementation 'com.google.android.gms:play-services-gcm:16.0.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.j256.ormlite:ormlite-android:5.1'
    implementation 'commons-io:commons-io:2.6'
    implementation "org.androidannotations:androidannotations-api:$AAVersion"
    implementation "org.androidannotations:ormlite-api:$AAVersion"

    implementation project(':binding')
    implementation project(':scanlib')

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

但是在构建时出现错误:

:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
AGPBI: "kind":"error","text":"Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl","sources":[],"tool":"D8"
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
:app:buildInfoGeneratorDebug

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
, D:\dev\mobile\\My Project\android\FM\app\build\intermediates\transforms\dexBuilder\debug\69.jar, D:\dev\mobile\\My Project\android\FM\app\build\intermediates\transforms\dexBuilder\debug\70.jar
  Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
107 actionable tasks: 7 executed, 100 up-to-date

【问题讨论】:

【参考方案1】:

只需清理并重建一切都会正常工作

【讨论】:

没有帮助。我清理,使缓存无效并重新启动。但得到同样的错误。 那么它可能会在 Android Studio 上安装任何新东西时出错。重新安装一次就行了 我重新安装了 Android Studio 3.2.1。但这无济于事。也许是因为我在我的应用程序中使用了任何模块?

以上是关于Android Studio 3.2.1:transformDexArchiveWithExternalLibsDexMergerForDebug 失败的主要内容,如果未能解决你的问题,请参考以下文章

更新至Android Studio 2.3.3中的gradle 3.2.1无效

将 Android Studio 升级到 3.2.1 后合并清单警告

Flutter - 获取 SHA-1 证书 - Android Studio 3.2.1

Android Studio 3.2.1中的USB调试问题

无法解析 Android Studio 3.2.1 中的依赖项

Android Studio (3.2.1) Instant Run 不适用于 Jacoco 0.8.2?