I am trying to run my android application through Proguard, however this keeps appearing:
Warning:Exception while processing task java.io.IOException: Can't write [C:\Users\Aliaksei\AndroidStudioProjects\SignOutSystem\app\build\intermediates\transforms\proguard\debug\jars\3\1f\main.jar] (Can't read [D:\Users\Aliaksei\.android\build-cache\f7a6034d02d095f18cc21950f131d07fa78b41c0\output\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [android/support/v4/os/j.class == classes.jar:android/support/v4/os/ResultReceiver$MyResultReceiver.class]))
I am aware that this means that the android.support.v4
is being declared twice somewhere, so I have tried adding exclude group: 'com.android.support', module: 'support-v4'
to any possible dependencies that might have it included, however that didn't work, even after a clean and rebuild.
Thinking I must have missed a dependency somewhere, I proceeded to add it to everything (Overkill), but that still hasn't worked.
Searching around, I found this snippet in similar posts and added this in the android section as well:
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
I have run out of ideas and searching for answers seems to take me to things I have already tried. Anything I'm missing?
app build.gradle
(A mess, with all the hacks above):
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
//apply plugin: 'com.getkeepsafe.dexcount'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.aliakseipilko.signoutsystem"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFile 'proguard-signoutsystem.txt'
}
debug {
minifyEnabled true
shrinkResources false
zipAlignEnabled true
proguardFile 'proguard-signoutsystem.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
//dexcount {
// format = "list"
// includeClasses = false
// includeFieldCount = true
// includeTotalMethodCount = true
// orderByMethodCount = true
// verbose = false
// maxTreeDepth = Integer.MAX_VALUE
// teamCityIntegration = false
// enableForInstantRun = false
//}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.android.support', module: 'support-v4'
}
compile('com.google.apis:google-api-services-sheets:v4-rev19-1.22.0') {
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.android.support', module: 'support-v4'
}
compile('com.google.android.gms:play-services-identity:9.2.0') {
exclude group: 'com.google.guava'
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.google.android.gms:play-services-auth:9.2.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.android.support:appcompat-v7:23.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.android.support:design:23.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.android.support:support-v4:23.4.0'
compile ('com.android.support:percent:23.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.squareup.okhttp3:okhttp:3.3.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.squareup.okhttp3:logging-interceptor:3.3.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.squareup.okio:okio:1.8.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.squareup.picasso:picasso:2.5.2') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('net.sf.biweekly:biweekly:0.4.6') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.github.tibolte:agendacalendarview:1.0.4') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.7heaven.widgets:segmentcontrol:1.14') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.survivingwithandroid:weatherlib:1.6.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.survivingwithandroid:weatherlib_okhttpclient:1.6.0'
compile files('libs/FDxSDKProAndroid.jar')
debugCompile ('com.squareup.leakcanary:leakcanary-android:1.5') {
exclude group: 'com.android.support', module: 'support-v4'
}
releaseCompile ('com.squareup.leakcanary:leakcanary-android-no-op:1.5') {
exclude group: 'com.android.support', module: 'support-v4'
}
testCompile ('com.squareup.leakcanary:leakcanary-android-no-op:1.5') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.jakewharton:butterknife:8.5.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
annotationProcessor ('com.jakewharton:butterknife-compiler:8.5.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
}
project build.gradle
:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha1'
classpath "io.realm:realm-gradle-plugin:3.0.0"
// classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Proguard rules:
#DEBUGGING
#-dontobfuscate
#-dontoptimize
###############
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-adaptresourcefilenames
-keep class com.aliakseipilko.signoutsystem.** { *; }
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.billing.IInAppBillingService
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-dontwarn sun.misc.Unsafe
-dontwarn okio.**
-dontwarn com.squareup.okhttp.**
-dontwarn biweekly.io.**
-dontwarn com.github.tibolte.**
-keep class com.github.tibolte.**
-keep class okio.**
-keep class biweekly.io.**
-keep class com.squareup.okhttp.**
-keep class SecuGen.FDxSDKPro.**
-keep class com.survivingwithandroid.**
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-dontwarn android.support.**
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }
-keep public class * extends android.support.v4.view.ActionProvider {
public <init>(android.content.Context);
}
-keepclasseswithmembernames class * {
native <methods>;
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep class *.R
-keepclasseswithmembers class **.R$* {
public static <fields>;
}
# Retain generated class which implement Unbinder.
-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }
# Prevent obfuscation of types which use ButterKnife annotations since the simple name
# is used to reflectively look up the generated ViewBinding.
-keep class butterknife.*
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
Any help would be appreciated.
The issue is butterknife
which is compiled with a higher support version (25.1.0
), so you may want to downgrade butterknife
or move all support library to 25.1.0
Here I've downgraded butterknife
to 8.0.1
:
dependencies {
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude module: 'httpclient'
}
compile('com.google.apis:google-api-services-sheets:v4-rev19-1.22.0') {
exclude module: 'httpclient'
}
compile 'com.google.android.gms:play-services-identity:9.2.0'
compile 'com.google.android.gms:play-services-auth:9.2.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:percent:23.4.0'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
compile 'com.squareup.okio:okio:1.8.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'net.sf.biweekly:biweekly:0.4.6'
compile 'com.github.tibolte:agendacalendarview:1.0.4'
compile 'com.7heaven.widgets:segmentcontrol:1.14'
compile 'com.survivingwithandroid:weatherlib:1.6.0'
compile 'com.survivingwithandroid:weatherlib_okhttpclient:1.6.0'
compile files('libs/FDxSDKProAndroid.jar')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile('com.squareup.leakcanary:leakcanary-android-no-op:1.5')
compile 'com.jakewharton:butterknife:8.0.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'
}
Then in your proguard.pro
to deal with warning :
-keep class com.fasterxml.** { *; }
-dontwarn com.fasterxml.**
-keep class biweekly.io.json.** { *; }
-dontwarn biweekly.io.json.**
-dontwarn java.lang.invoke**
-dontwarn sun.misc.Unsafe
-dontwarn okio.**
Note that I've also enabled multidex to build successfully : I've added multiDexEnabled true
to defaultConfig