【问题标题】:Can't generate signed APK in AndroidStudio, 'java.io.IOException'无法在 Android Studio 中生成签名的 APK,“java.io.IOException”
【发布时间】:2017-12-08 21:50:05
【问题描述】:

我在 Android Studio 中生成签名 APK 时遇到问题。

错误:任务 ':app:transformClassesWithMultidexlistForDebug' 执行失败。 java.io.IOException: 无法写入 [C:\Users\Ahmed\StudioProjects\android1\app\build\intermediates\multi-dex\debug\componentClasses.jar] (无法读取 [C:\Users\Ahmed .gradle\caches\transforms-1\files-1.1\support-compat-25.2.0.aar\8a6c38a056e2992b7f752213fb56ad15\jars\classes.jar(;;;;;;.class)] (重复的 zip 条目 [classes.jar: android/support/v4/view/ViewCompat.class]))

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'

defaultConfig {
    applicationId "com.ahmedkarray.switchsides.colorsdash"
    minSdkVersion 16
    targetSdkVersion 25
    multiDexEnabled true

    ndk {
        moduleName "player_shared"
    }
}

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


}
sourceSets.main {
    jni.srcDirs = []// <-- disable automatic ndk-build call
}
}
android{


configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
    all*.exclude group: 'com.android.support', module: 'support-annotations'
}
}

dependencies {
compile 'com.android.support:multidex:1.0.1'
compile ('com.google.android.gms:play-services:+'){exclude module: 'support-v4'}
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
compile ('com.android.support:multidex:1.0.1')
compile 'com.android.support:support-annotations:27.0.2'
}

【问题讨论】:

    标签: android gradle build apk


    【解决方案1】:

    以这种方式更改您的依赖项

    dependencies {
        compile 'com.android.support:multidex:1.0.1'
        compile ('com.google.android.gms:play-services:+'){
           exclude module: 'support-v4'
        }
        compile files('libs/dagger-1.2.2.jar')
        compile files('libs/javax.inject-1.jar')
        compile files('libs/nineoldandroids-2.4.0.jar')
        compile 'com.android.support:support-v4:27.0.2'
        compile 'com.android.support:mediarouter-v7:27.0.2'
        compile 'com.android.support:support-compat:27.0.2'
        compile 'com.android.support:support-core-ui:27.0.2'
        compile 'com.android.support:appcompat-v7:27.0.2'
        compile 'com.android.support:support-annotations:27.0.2'
    }
    

    更改也 compileSdkVersion

    android {
       compileSdkVersion 27
    

    并从您的 libs 文件夹中删除 support-v4-19.0.1.jar

    【讨论】:

      猜你喜欢
      • 2018-02-18
      • 2016-09-11
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-08
      • 1970-01-01
      相关资源
      最近更新 更多