java - 错误:Execution failed for task ':app:transformClassesWithMultidexlistForDebug

标签 java android

当我尝试制作项目时,显示以下错误,o 模拟:

我附上 AS 的图像,当显示所描述的错误时

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [H:\Server...

IMAGE

这是我的build.gradle,我不知道它有什么错误

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "codingwithmitch.com.googlemapsgoogleplaces"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'

    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:multidex:1.0.2'
    compile 'com.android.volley:volley:1.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
    compile (group: 'org.apache.httpcomponents' , name: 'httpmime' , version: '4.3.5') {
        exclude module: 'org.apache.httpcomponents:httpclient'}


    //Google play services
    compile 'com.google.android.gms:play-services:11.4.0'
}

谢谢

最佳答案

通过将 build.gradle 文件的值更改为 true 来启用 multidex -

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0"

         defaultConfig {
             minSdkVersion 14 //lower than 14 doesn't support multidex
             targetSdkVersion 22

             // Enabling multidex support.
             multiDexEnabled true
         }
}

dependencies {
    //need to add multidex dependency 
    compile 'com.android.support:multidex:1.0.1'
}

您还需要将其包含在您的 Application 类中:

public class Application extends MultiDexApplication  {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

}

Reference

关于java - 错误:Execution failed for task ':app:transformClassesWithMultidexlistForDebug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48040435/

相关文章:

android - 单击和取消单击时如何更改复选框颜色?

android - 在 Android RelativeLayout maxWidth 中不起作用

android - 如何使用 adb shell 启动我的 Android 应用程序?

java,为什么 thread.wait() 在我的代码中不起作用

java - juel表达式怎么写

java - 颜色随机排列

java - 将后端转换为模块。 IE。从 WAR 到 EAR 结构

android - Activity 未延伸到横向切口下方

java - 转换为 base64 并在结果中重复?

java - 如何用相似但不同的对象填充列表?