2

I'm having a hard time with dexguard to make it to do not remove a resource I access this way:

int resourceId=getResources().getIdentifier("pictures", "array", getActivity().getPackageName());

When I execute the application I get the following exception:

java.lang.RuntimeException: Unable to start activity android.content.res.Resources$NotFoundException: Array resource ID #0x0 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: android.content.res.Resources$NotFoundException: Array resource ID #0x0

I have used this directives in proguard-project.txt extracted from some related questions on stack overflow and solved nothing:

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

-keep class **.R$*

How can I tell dexguard to do not strip out this resource?

Thanks in advance.

Notbad
  • 5,936
  • 12
  • 54
  • 100
  • The question is about not removing unused resources, not removing them. Am I missing something? – Notbad Jul 09 '15 at 08:12

1 Answers1

2

Well after talking with dexguard creator it seems this can be achieved just by using:

-keepresources array/pictures
-keepresources array/a_*

Hope others will find this usseful

Cheers.

Notbad
  • 5,936
  • 12
  • 54
  • 100
  • is it working for you.i have face the same issue but not working for me in android studio – RamBabu Pudari Jul 21 '15 at 10:52
  • Yes, it is. I'm using android studio too. – Notbad Jul 21 '15 at 15:06
  • but my side i am getting some of the images. dexguard shrinking process remove the some of the files. i kept in my dexguard file -keep class **.R -keep class **.R$* { *; } #Keep the R -keepclassmembers class **.R$* { *; } -keepclassmembers class **.R* { *; } but no use. some of images only dipslaying – RamBabu Pudari Jul 22 '15 at 05:19
  • It is difficult from here to know exactly what is happening. You can contact dexguard programmer. It is a really helpful person. – Notbad Jul 22 '15 at 15:10
  • thanks for your replay. my self i found an answer. just keep the resources and remove the shrinking option. – RamBabu Pudari Jul 23 '15 at 10:18