构建项目

时间:2018-04-30 16:16:38

标签: java android android-studio android-gradle multidex

这是我的build.gradle

当我构建项目时出现此错误:

  

错误:任务':app:transformClassesWithMultidexlistForDebug'的执行失败。   java.io.IOException:无法写[D:\ Dev \ android \ fruit \ Fruit \ app \ build \ intermediates \ multi-dex \ debug \ componentClasses.jar](无法读取[C:\ Users \ bahrani .gradle \ caches \ transforms-1 \ files-1.1 \ support-core-ui-27.1.1.aar \ 7c83800d6960afec35a787899d518156 \ jars \ classes.jar(;;;;;; **。class)](重复的zip条目[ classes.jar:机器人/支持/设计/插件/ CoordinatorLayout $ Behavior.class]))

当我运行项目时出现此错误:

  

错误:任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'的执行失败。   com.android.builder.dexing.DexArchiveMergerException:无法合并dex

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"
    defaultConfig {
        applicationId "pinuit.app.ir.fruit"
        minSdkVersion 17
        targetSdkVersion 27
        multiDexEnabled true
        versionCode 3
        versionName "1.7"
        manifestPlaceholders = [onesignal_app_id               : "222c377a-7695-433c-b6a0-4edd3cd79771",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "REMOTE"]
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    repositories {
        mavenCentral()
    }
}

dependencies {
    compile ('com.android.support.constraint:constraint-layout:1.0.2'){
        exclude group: 'com.android.support', module:'support-v4'
    }
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile ('com.android.support:support-v4:27.0.2') {
        exclude group: 'com.android.support', module:'support-v4'
    }
    compile ('com.android.support:appcompat-v7:27.0.2') {
        exclude group: 'com.android.support', module:'support-v4'
    }
    compile ('com.android.support:cardview-v7:27.0.2') {
        exclude group: 'com.android.support', module:'support-v4'
    }
    compile ('com.android.support:recyclerview-v7:27.0.2') {
        exclude group: 'com.android.support', module:'support-v4'
    }
    compile ('com.android.support:design:27.0.2') {
        exclude group: 'com.android.support', module:'support-v4'
    }
    implementation 'it.sephiroth.android.library.bottomnavigation:bottom-navigation:2.0.1-rc1'
    implementation 'com.wang.avi:library:2.1.3'
    implementation('com.squareup.retrofit2:retrofit:2.1.0') {
        exclude module: 'okhttp'
    }
    implementation 'com.squareup.okhttp3:okhttp:3.4.1'
    implementation 'com.squareup.retrofit2:converter-gson:+'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.3.1'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'jp.wasabeef:glide-transformations:2.0.0'
    implementation 'com.onesignal:OneSignal:[3.8.3, 3.99.99]'
    implementation 'com.google.firebase:firebase-core:12.0.1'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
}


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

1 个答案:

答案 0 :(得分:1)

我在尝试将Unity3D项目导入Android Studio时看到了类似的错误。首先,我改变了'编译'#39;实施'见下面的链接

here

在我的情况下,我试图导入多个.aar文件,我发现此错误的解决方案是将所有.aar文件作为库单独导入。希望这会有所帮助