开发者

Proguard Android App for LVL and Fragment Compatibility Support

I'm trying to use Proguard against my app which will eventually incorporate LVL and In-app Billing. The problem I have is that Proguard keeps crashing my app on start and it's hard to figure out what's failing.

I'm using the Android V4 support compatibility library and it seems to be blowing away that library as well as some other stuff.

Does anyone has a proguard.cfg that works with a basic version of the v4 compat library for starters?

Currently I'm using the stock proguard.cfg which doesn't work.

-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 c开发者_如何学Golass 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 *;
}


That's not enough to produce a working application.. proguard will for example delete all your fragments by default, and there are some more compat. libraries it uses.

I've found the following works:

-dontwarn **CompatHoneycomb
-dontwarn **CompatHoneycombMR2
-dontwarn **CompatCreatorHoneycombMR2
-keep class android.support.v4.** { *; }

-keep public class * extends android.support.v4.**
-keep public class * extends android.app.Fragment

In theory if you simply want proguard as an obfuscator and are not ineterested in its other 'features', then

-dontshrink
-dontoptimize

Should switch it off. Even with that, though test thoroughly on a real android 1.6 phone. I didn't and found too late proguard had made a breaking change to the binary that only manifested on 1.6...


To have Proguard working with v4 compatibility library add this to your proguard.cfg:

-dontwarn **CompatHoneycomb
-keep class android.support.v4.** { *; }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜