Obfuscation not working when using Android support library

When I enable obfuscation on public members in my Android app, I get a fatal runtime error at app launch when I am using the Android support library.

Here is an example project that is identical to this project, except that I use AppCompatActivity instead of Activity.

security.tests.zip (47.0 KB)

The runtime error indicates that something in the appcompat library cannot be found in the apk when obfuscation is enabled.

java.lang.NoSuchFieldError: No static field abc_textfield_search_default_mtrl_alpha of type I in class Landroidx/appcompat/R$drawable; or its superclasses (declaration of 'androidx.appcompat.R$drawable' appears in base.apk)

ah yes! We generate the R file and this ends up being obfuscated, so it can’t find those fields. Consider it fixed.

2 Likes