How can I force Proguard to keep my .xml resource file?

前端 未结 3 1295
广开言路
广开言路 2020-12-03 17:33

I am succesfully using proguard for my Android apps.

However, with one app I am having trouble.

This app uses a java library that has a .xml fi

3条回答
  •  醉酒成梦
    2020-12-03 17:55

    You shoud add a new file keep.xml under res/raw.

    
    
    

    In tools:keep, you list the layouts you want to keep. You can even keep specefic drawables if you use reflection in your code to get your drawable

    tools:keep="@drawable/ico_android_home_infosperso"
    

    I prefer to add tools:shrinkMode="strict" so that i make sur no resource is eliminated unless it is not used for sure. You may want to have a look at this link Shrink your code. Don't Forget to add these lines to your proguard rules:

    -keepattributes InnerClasses -keep class **.R -keep class **.R$* { ; }

提交回复
热议问题