【问题标题】:Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. >错误:任务“:app:transformClassesWithMultidexlistForDebug”执行失败。 >
【发布时间】:2018-06-09 18:18:56
【问题描述】:

错误:任务 ':app:transformClassesWithMultidexlistForDebug' 执行失败。

java.io.IOException: 无法写入 [C:\Users\ACERNRC\Desktop\WORK\woo\woo_1\FashionsNrc\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can' t 读取 [C:\Users\ACERNRC.gradle\caches\transforms-1\files-1.1\Woocommerce-Android-Client-0.0.3.aar\c97bb2466b99eaef9958dcb4fe44dc0d\jars\libs\google-http-client-1.20.0. jar(;;;;;;**.class)] (重复的 zip 条目 [google-http-client-1.20.0.jar:com/google/api/client/json/JsonPolymorphicTypeMap$TypeDef.class]))

如何解决?

这是我的应用程序 gradle 文件,在 multidex 选项隐藏在默认配置后

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.acernrc.fashionsnrc"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
       // multiDexEnabled true
      /**  dexOptions {

            jumboMode true
            javaMaxHeapSize "4g"

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

repositories {
    jcenter()

    maven {
        url "https://jitpack.io"
    }
}
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  'com.github.rajatady:Woocommerce-Android-Client:0.0.3'
    implementation  'com.github.vajro:MaterialDesignLibrary:1.6'
    implementation  'com.github.ozodrukh:CircularReveal:1.3.1@aar'
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
    implementation project(':woocommerce')
}

同步节目后 错误:任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' 执行失败。

java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: 无法合并dex

【问题讨论】:

标签: java android android-studio gradle


【解决方案1】:

在您的 local.properties 文件中,只需添加下面提到的大小

org.gradle.jvmargs=-XX:MaxHeapSize\=512m -Xmx512m

在你的应用程序中

defaultConfig {
    applicationId "<PACKAGE NAME>"
    minSdkVersion 8
    versionCode 1
    versionName "1.0"
    targetSdkVersion 26

    multiDexEnabled true //this is important
}

【讨论】:

  • 文件中有一条注释为This file is automatically generated by Android Studio. Do not modify this file -- YOUR CHANGES WILL BE ERASED!
【解决方案2】:

试试这个

build.gradle:

defaultConfig {
   multiDexEnabled true
}

dependencies {
implementation  'com.android.support:multidex:1.0.1'
}

清理您的项目并重建。

【讨论】:

    【解决方案3】:

    在 build.gradle 中:

    defaultConfig {
       multiDexEnabled true
    }
    
    
    dependencies {
    implementation  'com.android.support:multidex:1.0.3'
    }
    

    但是注意你使用的是旧版本的sdk

    【讨论】:

      猜你喜欢
      • 2016-01-23
      • 2018-08-01
      • 2018-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多