-3

I am unsuccessfully trying to generate a signed APK.

My proguard-rules.pro file:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-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.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

# ================ Google Play Services ================
-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}
# ======================================================

# ============ Corrige erros de compilação =============
-dontwarn android.support.**
-keeppackagenames org.jsoup.nodes
-dontwarn okio.**
# ======================================================

# ==== crashlytics ====
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
# =====================

My dependencies:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services-ads:9.2.0'
    compile 'com.google.android.gms:play-services-analytics:9.2.0'
    compile 'com.android.support:design:23.4.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
    compile 'org.jsoup:jsoup:1.9.2'
    compile 'com.github.hotchemi:android-rate:1.0.1'
    compile 'com.github.curioustechizen.android-ago:library:1.3.2'
    compile 'com.jakewharton:butterknife:8.0.1'
    apt 'com.jakewharton:butterknife-compiler:8.0.1'
    compile 'com.amitshekhar.android:android-networking:0.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
}

The build error:

Error:Execution failed for task ':mobile:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.
:mobile:transformClassesAndResourcesWithProguardForRelease FAILED
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
JBarbosa
  • 134
  • 8

1 Answers1

1

If all you want to do is create a signed APK, just add the

-ignorewarnings

flag to your proguard-rules.pro file. This will ignore all warnings emitted by Proguard and simply generate the signed APK.

However, it is likely that ignoring all warnings in this manner will have several unintended consequences (critical classes stripped out, impaired functionality and so on). I would strongly urge you to examine each of the warnings emitted and deal with each one separately. Either properly handle each of the warnings in the prescribed manner or use the

-dontwarn

flag for the particular class or library if the warning is spurious.

Iterate the process till all such side-effects are eliminated, and you will have a Proguard-optimized APK with no problems.

Yash Sampat
  • 30,051
  • 12
  • 94
  • 120