I added the Google Play Services application to the application. Everything works fine, but the size of my apk increases 4 (!) Times from 350 KB to 1.6 MB. To remove unused classes from the Google Play Services library, I decided to use ProGuard. But now I can not start the project or export it to apk, because ProGuard returned an error. When I do not use GPS lib, I have no problems with export, but I can not create apk with this library. I read a lot about this problem, but any solution I found did not help me.
Here is my proguard-project.txt (as recommended here )
-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; }
Here is my proguard.cng
-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 #keep all classes that might be used in XML layouts -keep public class * extends android.view.View -keep public class * extends android.app.Fragment -keep public class * extends android.support.v4.Fragment #keep all public and protected methods that could be used by java reflection -keepclassmembernames class * { public protected <methods>; } -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 *; } -dontwarn **CompatHoneycomb -dontwarn org.htmlcleaner.* -dontwarn com.google.android.gms.** -keep class com.google.android.gms.common.GooglePlayServicesUtil {*;} -keep class com.google.ads.** { *;}
and here is the error I received after exporting to apk:
[2014-06-20 23:11:38 - Dictionary] Proguard returned with error code 1. See console [2014-06-20 23:11:38 - Dictionary] You should check if you need to specify additional program jars. [2014-06-20 23:11:38 - Dictionary] Unexpected error while performing partial evaluation: [2014-06-20 23:11:38 - Dictionary] Class = [com/google/android/gms/common/GooglePlayServicesUtil] [2014-06-20 23:11:38 - Dictionary] Method = [showErrorDialogFragment(ILandroid/app/Activity;ILandroid/content/DialogInterface$OnCancelListener;)Z] [2014-06-20 23:11:38 - Dictionary] Exception = [java.lang.IllegalArgumentException] (Can't find any super classes of [com/google/android/gms/common/SupportErrorDialogFragment] (not even immediate super class [android/support/v4/app/DialogFragment])) [2014-06-20 23:11:38 - Dictionary] java.lang.IllegalArgumentException: Can't find any super classes of [com/google/android/gms/common/SupportErrorDialogFragment] (not even immediate super class [android/support/v4/app/DialogFragment]) [2014-06-20 23:11:38 - Dictionary] at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:299) [2014-06-20 23:11:38 - Dictionary] at proguard.evaluation.value.IdentifiedReferenceValue.generalize(IdentifiedReferenceValue.java:65) [2014-06-20 23:11:38 - Dictionary] at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:481) [2014-06-20 23:11:38 - Dictionary] at proguard.evaluation.Variables.generalize(Variables.java:136) [2014-06-20 23:11:38 - Dictionary] at proguard.evaluation.TracedVariables.generalize(TracedVariables.java:118) [2014-06-20 23:11:38 - Dictionary] at proguard.optimize.evaluation.PartialEvaluator.evaluateSingleInstructionBlock(PartialEvaluator.java:682) [2014-06-20 23:11:38 - Dictionary] at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlock(PartialEvaluator.java:602) [2014-06-20 23:11:38 - Dictionary] at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlockAndExceptionHandlers(PartialEvaluator.java:560) [2014-06-20 23:11:38 - Dictionary] at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute0(PartialEvaluator.java:264) [2014-06-20 23:11:38 - Dictionary] at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute(PartialEvaluator.java:181) [2014-06-20 23:11:38 - Dictionary] at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:101) [2014-06-20 23:11:38 - Dictionary] at proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:79) [2014-06-20 23:11:38 - Dictionary] at proguard.classfile.attribute.visitor.AllAttributeVisitor.visitProgramMember(AllAttributeVisitor.java:95) [2014-06-20 23:11:38 - Dictionary] at proguard.classfile.util.SimplifiedVisitor.visitProgramMethod(SimplifiedVisitor.java:91) [2014-06-20 23:11:38 - Dictionary] at proguard.classfile.ProgramMethod.accept(ProgramMethod.java:71) [2014-06-20 23:11:38 - Dictionary] at proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:504) [2014-06-20 23:11:38 - Dictionary] at proguard.classfile.visitor.AllMethodVisitor.visitProgramClass(AllMethodVisitor.java:47) [2014-06-20 23:11:38 - Dictionary] at proguard.classfile.ProgramClass.accept(ProgramClass.java:346) [2014-06-20 23:11:38 - Dictionary] at proguard.classfile.ClassPool.classesAccept(ClassPool.java:116) [2014-06-20 23:11:38 - Dictionary] at proguard.optimize.Optimizer.execute(Optimizer.java:372) [2014-06-20 23:11:38 - Dictionary] at proguard.ProGuard.optimize(ProGuard.java:306) [2014-06-20 23:11:38 - Dictionary] at proguard.ProGuard.execute(ProGuard.java:115) [2014-06-20 23:11:38 - Dictionary] at proguard.ProGuard.main(ProGuard.java:492)
maybe something is wrong with my local settings ... I tried -dontwarn and -dontwarn different classes, but now nothing helped ...
Please help me!
source share