Proguard missing class R$raw not resolved by -keep class

105 views Asked by At

I'm trying to build my app that uses R.raw.resource_name, but i get the following error:

Missing class my.package.name.R$raw (referenced from: void my.package.name.ClassName.<init>(android.content.Context, boolean, java.util.List))

Adding this line to proguard-rules.pro doesn't resolve the error:

-keep class my.package.name.R$raw

-dontwarn with the same class allows to build the app, but fails in runtime:

-dontwarn my.package.name.R$raw

What is the proper way to handle this?

2

There are 2 answers

0
Daniil On BEST ANSWER

I've found the issue, when renaming a raw file without extension Android Studio adds a dot in the end. So the issue was that i had tmp. file inistead of tmp. This was not detected in the syntax highlighting, but failed the buid. Renaming the file helped.

0
Rico Wind On

I validated your problem in Android Studio Hedgehog | 2023.1.1 Patch 2.

I have filed https://issuetracker.google.com/326180138 to track this in studio.

Studio should not rename the file tmp. and aapt2 should (potentially) not just ignore the file