Proguard Android 应用程序提供 LVL 和片段兼容性支持
我正在尝试对我的应用程序使用 Proguard,该应用程序最终将合并 LVL 和应用内计费。我遇到的问题是 Proguard 在启动时不断使我的应用程序崩溃,并且很难找出失败的原因。
我正在使用 Android V4 支持兼容性库,它似乎让该库以及其他一些东西都大吃一惊。
有人有一个 proguard.cfg 可以与 v4 兼容库的基本版本一起使用吗?
目前我正在使用库存 proguard.cfg ,但它不起作用。
-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 *;
}
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 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 *;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这还不足以生成一个工作应用程序。例如,proguard 将默认删除所有片段,并且还有一些更多的兼容性。它使用的库。
我发现了以下作品:
理论上,如果您只是想将 proguard 作为混淆器并且对其其他“功能”不感兴趣,那么
应该将其关闭。即便如此,在真正的 android 1.6 手机上进行彻底测试。我没有,并且发现为时已晚,proguard 对二进制文件进行了重大更改,该更改仅在 1.6 上体现......
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:
In theory if you simply want proguard as an obfuscator and are not ineterested in its other 'features', then
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...
要让 Proguard 使用 v4 兼容性库,请将其添加到您的 proguard.cfg 中:
To have Proguard working with v4 compatibility library add this to your proguard.cfg: