Proguard Android 应用程序提供 LVL 和片段兼容性支持

发布于 2024-11-09 12:44:28 字数 1444 浏览 5 评论 0原文

我正在尝试对我的应用程序使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月打碎记忆 2024-11-16 12:44:28

这还不足以生成一个工作应用程序。例如,proguard 将默认删除所有片段,并且还有一些更多的兼容性。它使用的库。

我发现了以下作品:

-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

理论上,如果您只是想将 proguard 作为混淆器并且对其其他“功能”不感兴趣,那么

-dontshrink
-dontoptimize

应该将其关闭。即便如此,在真正的 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:

-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...

倾城月光淡如水﹏ 2024-11-16 12:44:28

要让 Proguard 使用 v4 兼容性库,请将其添加到您的 proguard.cfg 中:

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

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

-dontwarn **CompatHoneycomb
-keep class android.support.v4.** { *; }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文