I'm trying to make a signed apk using a proguard. An error occurs:
Warning: Exception while processing task java.io.IOException: Can not write [C: \ Android \ App \ Project \ app \ build \ intermediates \ transforms \ proguard \ release \ jars \ 3 \ 1f \ main.jar] (Can 'T read [C: \ users \ user \ .gradle \ caches \ modules-2 \ files-2.1 \ com.google.code.gson \ gson \ 2.7 \ 751f548c85fa49f330cecbb1875893f971b33c4e \ gson-2.7.jar (;;;;;; **. Class)] (Duplicate zip entry [com / google / a / a / a.class == gson-2.7.jar: com / google / gson / annotations / Expose.class]))
Error: Execution failed for task ': app: transformClassesAndResourcesWithProguardForRelease'.
Job failed, see logs for details
The proguard-rules.pro file I configured
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class com.exp.data.** { *; }
-dontwarn com.google.common.**
-dontwarn com.google.gson.**
-dontwarn retrofit2.converter.gson.**
-dontwarn retrofit2.Platform$Java8
-dontwarn okio.**
-dontwarn org.apache.commons.io.FilenameUtils
-keep class okio.**
Why can an error occur?
I'm using a build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "ru.vintegra.sale"
minSdkVersion 21
targetSdkVersion 25
versionCode 41
versionName '1.41'
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v13:25.3.1'
compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.google.android.gms:play-services-vision:11.0.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:converter-scalars:2.1.0'
compile 'com.squareup.okhttp3:okhttp:3.4.2'
}
You can try this snippet:
########### OkHttp3 ###########
-keepattributes Signature
-keepattributes *Annotation*
-keep,includedescriptorclasses class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
-dontnote okhttp3.**
######### OkHttp3 end #########
########### OkHttp URL Connection ###########
-keep class com.squareup.okhttp3.** { *; }
-keep interface com.squareup.okhttp3.** { *; }
-dontwarn com.squareup.okhttp3.**
-dontnote com.squareup.okhttp3.**
########### OkHttp URL Connection end ###########
-keep class com.google.android.gms.**
-keepclassmembers class com.google.android.gms.** {
*;
}
-keep class com.google.gson.**
-keepclassmembers class com.google.gson.** {
*;
}
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.