简体   繁体   中英

Error generating signed Apk with proguard activated in Android Studio 3

I cannot create a signed apk if proguard is active. If not it works. The error is:

Warning:Exception while processing task java.io.IOException: Can't write [C:\\Users....\\AndroidStudioProjects\\BStats\\app\\build\\intermediates\\transforms\\proguard\\release\\0.jar] (Can't read [C:\\Users.....gradle\\caches\\transforms-1\\files-1.1\\play-services-auth-base-11.0.1.aar\\37c6010cc8e9c38e6022a124120862be\\jars\\classes.jar(;;;;;;**.class)] (Duplicate zip entry [com/google/android/gms/b/ju.class == classes.jar:com/google/android/gms/internal/zzei.class])) Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.

my gradle file:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:animated-vector-drawable:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:customtabs:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'

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'

// Facebook stuff
// Android SDK
implementation 'com.facebook.android:facebook-android-sdk:4.+'
// Audience Network SDK. Only versions 4.6.0 and above are available
implementation 'com.facebook.android:audience-network-sdk:4.+'
// Account Kit
implementation 'com.facebook.android:account-kit-sdk:4.+'

Why is it complaining about play-services-auth-base-11.0.1.aar if I don't even use it? Why does it work if not using proguard?

Apreciate your help. Other similar cases use the libs that are being nominated, and the fix is just a matter of having the right versions. This is not the case.

My proguard: -keepattributes Signature -dontwarn com.google.android.gms.** - if not I have lots of warnings - and I don't even use com.google.android.gms in my app.

Thanks.

Delete build folder from app and run if not work than try Invalidate Caches/Restart.

Happy coding!!

Very strange...

I made this change:

// Android SDK
implementation( 'com.facebook.android:facebook-android-sdk:4.+' ){
    exclude group: 'com.google.android.gms'
}

// Audience Network SDK. Only versions 4.6.0 and above are available
implementation( 'com.facebook.android:audience-network-sdk:4.+'){
    exclude group: 'com.google.android.gms'
}

// Account Kit
implementation( 'com.facebook.android:account-kit-sdk:4.+'){
            exclude group: 'com.google.android.gms'
}

And now the APK is being generated with Proguard. I didn't test it yet to see if the Facebook integration works properly. In case it does, I think this should be better explanined in the documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM