Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard vs Annotations

Tags:

I have an app that uses ActiveAndroid, a database ORM library, that relies on annotations.

@Table(name="test") public class DatabaseItem extends ActiveRecordBase<DatabaseItem> {      public DatabaseItem(Context context) {         super(context);         // TODO Auto-generated constructor stub     }      @Column(name="counter")     public int counter;  } 

How do I get Proguard working nicely with this? Currently, I get errors about not finding a column name by ActiveAndroid when using Proguard. I guess it somehow mangles the annotation.

My relevant Proguard configuration:

#ActiveAndroid -keep public class com.activeandroid.** -keep public class * extends com.activeandroid.ActiveRecordBase -keepattributes Column -keepattributes Table 
like image 997
Peterdk Avatar asked Sep 11 '11 13:09

Peterdk


People also ask

What is ProGuard rule?

What is ProGuard? ProGuard is a free java tool in Android, which helps us to do the following, Shrink(Minify) the code: Remove unused code in the project. Obfuscate the code: Rename the names of class, fields, etc. Optimize the code: Do things like inlining the functions.

How do you keep all classes in ProGuard?

-keepclassmembernames. This is the most permissive keep directive; it lets ProGuard do almost all of its work. Unused classes are removed, the remaining classes are renamed, unused members of those classes are removed, but then the remaining members keep their original names.

Does ProGuard remove unused classes?

ProGuard Facts:Helps to remove unused classes, members & fields. It removes unused codes from your libraries as well. (Which means, any method or field that is not referenced anywhere will be removed by ProGuard Shrinker). Helps to reduce the build size by obfuscating the classes, methods, & fields with short names.

What is ProGuard Dontwarn?

-dontwarn [class_filter] Specifies not to warn about unresolved references and other important problems at all. The optional filter is a regular expression; ProGuard doesn't print warnings about classes with matching names. Ignoring warnings can be dangerous.


1 Answers

Column and Table aren't existing java class file attributes. You'll at least have to specify

-keepattributes *Annotation* 

Cfr. the ProGuard manual.

like image 64
Eric Lafortune Avatar answered Nov 29 '22 06:11

Eric Lafortune