Recently I started to get a few random reports of this error on google play vitals:
Fatal Exception: java.lang.RuntimeException
An error occurred while executing doInBackground() (AsyncTask.java:354)
Caused by android.content.res.Resources$NotFoundException
Drawable drawable/mr_button_light_static with resource ID #0x7f080195
...
android.content.res.XResources.getDrawable (XResources.java:770)
androidx.mediarouter.app.MediaRouteButton$RemoteIndicatorLoader.doInBackgroundd
androidx.mediarouter.app.MediaRouteButton$RemoteIndicatorLoader.doInBackground
...
Caused by android.content.res.Resources$NotFoundException
Drawable (missing name) with resource ID #0x7f08012b
It seems to come from this code in MediaRouteButton: https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-mediarouter-release/mediarouter/mediarouter/src/main/java/androidx/mediarouter/app/MediaRouteButton.java#812
@Override
protected Drawable doInBackground(Void... params) {
Drawable.ConstantState remoteIndicatorState = sRemoteIndicatorCache.get(mResId);
if (remoteIndicatorState == null) {
return mContext.getResources().getDrawable(mResId);
} else {
return null;
}
}
So at first I was blaming R8 resource shrinking, but inspecting the .aab bundle I was able to find the file under res/drawable/mr_button_light_static.xml with valid xml content:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/ic_mr_button_connected_30_light"
android:state_checked="true"
android:state_enabled="true"/>
<item
android:drawable="@drawable/ic_mr_button_disconnected_light"
android:state_enabled="true"/>
<item android:drawable="@drawable/ic_mr_button_disabled_light"/>
</selector>
Something weird is that it's only happening in a few Pixel 3 devices (Pixel 3a and Pixel 3 XL, Android 9)
I already tried excluding this file from R8 shrinker, but as I said, the file is correctly bundled. So I'm wondering if this might be some issue with the APK that google plays generates for those devices? Any suggestion?
I'm currently using this version of mediarouter:
implementation 'androidx.mediarouter:mediarouter:1.2.3'