簡體   English   中英

在Android Studio中生成簽名的APK時出錯

[英]Error while generating a signed apk in Android Studio

我想從我的項目中生成一個apk文件,但是在生成簽名的apk時卻不斷出現此錯誤:

Execution failed for task ':app:transformClassesWithJarMergingForRelease'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$PrintHelperStubImpl.class

自6個小時以來,我一直在尋找解決方案,而我幾乎嘗試了所有方法,但無法解決。 有誰知道如何解決這一問題?

這是我的成就:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.2"
    dexOptions {
    javaMaxHeapSize "4g"
}

defaultConfig {
    applicationId "com.pake.lightbulb"
    minSdkVersion 14
    targetSdkVersion 26
    multiDexEnabled true

    ndk {
        moduleName "player_shared"
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
       'proguard-rules.txt'
    }
}
sourceSets.main
        {
            jni.srcDirs=[]
        }

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

dependencies {
    compile('com.google.android.gms:play-services:+')
    compile files('libs/dagger-1.2.2.jar')
    compile files('libs/javax.inject-1.jar')
    compile files('libs/nineoldandroids-2.4.0.jar')
}

很有可能還通過play-services依賴項包含了support-v4庫。 要排除它,請將gradle的相關依賴項行gradle為:

compile('com.google.android.gms:play-services:+')
{
    exclude module: 'support-v4'
}

要對其進行更多故障排除並檢查其他重復項和沖突,請檢查gradle的依賴關系樹命令:

gradle -q dependencies --configuration compile

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM