Olsi Saqe
Olsi Saqe

Reputation: 383

proguard and R in android

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?

Upvotes: 4

Views: 2922

Answers (1)

Johnny Z
Johnny Z

Reputation: 15457

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>;
}

Upvotes: 3

Related Questions