Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 941
Some Noob Student Avatar asked Nov 15 '12 16:11

Some Noob Student


People also ask

What is ProGuard configuration?

ProGuard is a tool to help minify, obfuscate, and optimize your code. It is not only especially useful for reducing the overall size of your Android application as well as removing unused classes and methods that contribute towards the intrinsic 64k method limit of Android applications.

Where is ProGuard config file?

By default, this file is located at the root of the module (next to the build. gradle file).

How does ProGuard obfuscation work?

In the obfuscation step, ProGuard renames classes and class members that are not entry points. In this entire process, keeping the entry points ensures that they can still be accessed by their original names. The preverification step is the only step that doesn't have to know the entry points.

What is the difference between ProGuard and R8?

R8 is having a faster processing time than Proguard which reduces build time. R8 gives better output results than Proguard. R8 reduces the app size by 10 % whereas Proguard reduces app size by 8.5 %. The android app having a Gradle plugin above 3.4.


1 Answers

No you do not.

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

-keep class com.actionbarsherlock.** {*;}
-keep class org.holoeverywhere.** {*;}
like image 152
Some Noob Student Avatar answered Oct 26 '22 19:10

Some Noob Student