【问题标题】:Proguard keep class actionbarsherlockProguard保持类actionbarsherlock
【发布时间】:2012-08-03 19:59:10
【问题描述】:

-keep class com.actionbarsherlock.** { *; }

在我的 proguard 配置中。正如 Actionbarsherlock 家伙所建议的(请参阅 http://actionbarsherlock.com/faq.html)。 但只有在添加之后

-keep public class * extends com.actionbarsherlock.app.SherlockFragment

保留了扩展 SherlockFragment 的类,因此我可以使用 Fragments。

为什么?

【问题讨论】:

  • 我很好奇,您是否已将您的 SDK 工具更新到至少 r20?自今年 6 月以来,他们应该在 xml safe with proguard (developer.android.com/tools/sdk/tools-notes.html) 中使用自定义视图:"Added automatic ProGuard support for the aapt -G flag. This change causes the build system to generate a temporary ProGuard keep-rules file containing classes that are referenced from XML files (such as custom views) and pass this to ProGuard at shrink-time."

标签: java android obfuscation actionbarsherlock proguard


【解决方案1】:

假设您有以下片段声明,用于 xml 布局:

public class MyFragment extends SherlockFragment {
    …
}

MyFragment 类不在 com.actionbarsherlock.* 包中,所以 ProGuard 会混淆类名。为了保留可能在 xml 布局中使用的类,请添加以下参数:

# keep all classes that might be used in XML layouts
-keep public class * extends android.view.View
-keep public class * extends android.view.ViewGroup
-keep public class * extends android.support.v4.app.Fragment

【讨论】:

  • 你能看一下我离开 OP 的评论吗?我认为从 SDK 工具 r20 开始,自定义视图已经可以安全地与 proguard 一起使用。
猜你喜欢
  • 2012-12-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-16
  • 2012-06-24
  • 1970-01-01
  • 1970-01-01
  • 2013-03-25
相关资源
最近更新 更多