When using Proguard, do you need a separate config for each referenced library?

梦想的初衷 提交于 2019-12-03 13:40:58

问题


My application has references to HoloEverywhere and SherlockActionBar, both which are in-workspace projects. When I enabled Proguard for the application only, it crashes giving these errors:

11-15 11:50:11.090: E/AndroidRuntime(24823): Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.app.Activity, int]
11-15 11:50:11.090: E/AndroidRuntime(24823):    at com.actionbarsherlock.a.a(Unknown Source)
11-15 11:50:11.090: E/AndroidRuntime(24823):    at org.holoeverywhere.a.a.l(Unknown Source)
11-15 11:50:11.090: E/AndroidRuntime(24823):    at org.holoeverywhere.a.a.setContentView(Unknown Source)

Is this because I only enabled Proguard for the app and not the other in-workspace projects HE and ABS?

I am using the default proguard-project.txt in the sdk and did not add any additional rules.


回答1:


No you do not.

Use these rules to keep the referenced classes un-obfuscated.

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



回答2:


this also will help

## ActionBarSherlock 4.4.0 specific rules ##

-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keepattributes *Annotation*

## hack for Actionbarsherlock 4.4.0, see        https://github.com/JakeWharton/ActionBarSherlock/issues/1001 ##
-dontwarn com.actionbarsherlock.internal.**


来源:https://stackoverflow.com/questions/13402408/when-using-proguard-do-you-need-a-separate-config-for-each-referenced-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!