4

I'm using proguard for the first time with my android app.

I'm not getting it working correctly. I was looking at my usage.txt file to see what was the part's that proguard deleted from my code.

I see this unusual things and didn't know what to think:

 [my_package].Manifest
    [my_package].Manifest$permission
    [my_package].R$array
    [my_package].R$attr
    [my_package].R$bool
    [my_package].R$color
    [my_package].R$dimen
    [my_package].R$id
    [my_package].R$integer
    [my_package].R$layout
    [my_package].R$menu
    [my_package].R$raw
    [my_package].R$string
    [my_package].R$style
    [my_package].R$styleable

Is proguard deleting all this content from my code?

Olsi Saqe
  • 383
  • 5
  • 12
  • Your program works after using proguard? – ramaral Oct 08 '13 at 14:10
  • No, proguard is causing some errors on my app. I think is also because of some reflections i'm calling. I'm working with the keep option to avoid removing / renaming this methods and classes. – Olsi Saqe Oct 08 '13 at 14:15
  • Yes, when we use reflection we must use keep option. – ramaral Oct 08 '13 at 14:25
  • Possible duplicate of [Proguard makes reflection with the R class in android application no longer work](http://stackoverflow.com/questions/13923815/proguard-makes-reflection-with-the-r-class-in-android-application-no-longer-work) – Flow May 27 '16 at 15:37

1 Answers1

3

Add this to your proguard configuration:

#Keep the R
-keepclassmembers class **.R$* {
    public static <fields>;
}

and look at this for a generic android proguard setup: Android: What are the recommended configurations for Proguard?

EDIT: For reflection add this:

-keepattributes InnerClasses

-keep class **.R
-keep class **.R$* {
    <fields>;
}
Community
  • 1
  • 1
Johnny Z
  • 14,329
  • 4
  • 28
  • 35
  • That's already in `${sdk.dir}/tools/proguard/proguard-android.txt` so you shouldn't need to specify that again. – zapl Oct 08 '13 at 14:34
  • I'm using: ${sdk.dir}/tools/proguard/proguard-android-optimize.txt so i think i already have this lines added – Olsi Saqe Oct 08 '13 at 14:36
  • See this. http://stackoverflow.com/questions/13923815/proguard-makes-reflection-with-the-r-class-in-android-application-no-longer-work – Johnny Z Oct 08 '13 at 14:44