android-maps-utils: Fatal Exception: android.content.res.Resources$NotFoundException: Resource ID
Summary:
The map randomly crashes while setting up the cluster manager and rendering the clusters.
Steps to reproduce: This is happening intermittently so it is hard to reproduce. See logs for more details.
Crashlytics Logs
Fatal Exception: android.content.res.Resources$NotFoundException: Resource ID #0x7f08005e at android.content.res.ResourcesImpl.getValueForDensity + 240(ResourcesImpl.java:240) at android.content.res.Resources.getDrawableForDensity + 885(Resources.java:885) at android.content.res.Resources.getDrawable + 828(Resources.java:828) at android.content.res.Resources.getDrawable + 803(Resources.java:803) at com.google.maps.android.ui.BubbleDrawable.(BubbleDrawable.java:3) at com.google.maps.android.ui.IconGenerator.(IconGenerator.java:3) at com.google.maps.android.clustering.view.DefaultClusterRenderer.(DefaultClusterRenderer.java:12) at com.google.maps.android.clustering.ClusterManager.(ClusterManager.java:9) at com.google.maps.android.clustering.ClusterManager.(ClusterManager.java:9) at com.ojoelectric.ojo.ui.map.ScooterMapFragment.onMapReady + 179(ScooterMapFragment.java:179) at com.google.android.gms.maps.zzak.zza(zzak.java:1) at com.google.android.gms.maps.internal.zzaq.dispatchTransaction(zzaq.java:1) at com.google.android.gms.internal.maps.zzb.onTransact + 22(zzb.java:22) at android.os.Binder.transact + 656(Binder.java:656) at hq.b + 14(hq.java:14) at com.google.android.gms.maps.internal.be.a + 4(be.java:4) at com.google.maps.api.android.lib6.impl.bj.run + 4(bj.java:4) at android.os.Handler.handleCallback + 790(Handler.java:790) at android.os.Handler.dispatchMessage + 99(Handler.java:99) at android.os.Looper.loop + 175(Looper.java:175) at android.app.ActivityThread.main + 6724(ActivityThread.java:6724) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 438(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main + 810(ZygoteInit.java:810)
Device and Android version:
-
LG Premiere Pro and LG Stylo 4 (8.1.0)
-
Galaxy J7 Crown (8.0) and Galaxy S8+ (7.1.2) and Galaxy Tab E 8.0 (7.1.1)
-
ZTE ZFive C LTE (7.1.1) and Z999 (7.1.2)
-
OnePlus 5T and OnePlus 6 (9.0)
-
Pixel XL (9.0)
-
AlcatelOneTouch (7.0)
-
XiaoMi 5 (8.0)
-
Coolpad Legacy (9.0)
I am using the following google map dependencies:
ext.googlePlayServicesVersion = "16.0.0"
implementation "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
implementation "com.google.android.gms:play-services-maps:$googlePlayServicesVersion"
kapt "com.google.android.gms:play-services-maps:$googlePlayServicesVersion"
implementation 'com.google.maps.android:android-maps-utils:0.5'
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 30 (11 by maintainers)
Commits related to this issue
- Merge remote-tracking branch 'googleOrigin/master' * googleOrigin/master: (107 commits) Remove unnecessary interface method public modifiers. (#587) Remove unnecessary primitives boxing. (#586) ... — committed to pauminku/android-maps-utils by pauminku 5 years ago
- fix: Copy xhdpi resources into default drawable folder This should avoid Resources$NotFoundException, possibly due to app being distributed as an Android App Bundle. Fixes #532 — committed to googlemaps/android-maps-utils by barbeau 4 years ago
- fix: Copy xhdpi resources into default drawable folder (#731) This should avoid Resources$NotFoundException, possibly due to app being distributed as an Android App Bundle. Fixes #532 — committed to googlemaps/android-maps-utils by barbeau 4 years ago
- chore(release): 1.3.2 [skip ci] ## [1.3.2](https://github.com/googlemaps/android-maps-utils/compare/v1.3.1...v1.3.2) (2020-05-27) ### Bug Fixes * Copy xhdpi resources into default drawable folder (... — committed to googlemaps/android-maps-utils by semantic-release-bot 4 years ago
- fix: Copy drawables to drawable-xxxhdpi Closes #532 — committed to googlemaps/android-maps-utils by barbeau 3 years ago
- fix: Copy drawables to drawable-xxxhdpi Closes #532 — committed to googlemaps/android-maps-utils by barbeau 3 years ago
- fix: Copy drawables to drawable-xxxhdpi (#856) Closes #532 — committed to googlemaps/android-maps-utils by barbeau 3 years ago
- chore(release): 2.2.3 [skip ci] ## [2.2.3](https://github.com/googlemaps/android-maps-utils/compare/v2.2.2...v2.2.3) (2021-04-28) ### Bug Fixes * Copy drawables to drawable-xxxhdpi ([#856](https://... — committed to googlemaps/android-maps-utils by semantic-release-bot 3 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Found this today in a Pixel 3A (Android 11 API 30) using
play_services_maps 17.0.0
andandroid_maps_utils 2.1.0
:First time ever happened, same use case as the author. Build > Clean Project fixed the issue (so far).
🎉 This issue has been resolved in version 1.3.2 🎉
The release is available on GitHub release
Your semantic-release bot 📦🚀
It looks like the root cause of this may be that in
BubbleDrawable
, the shadow and mask PNG resources are only defined in thedrawable-xhdpi
anddrawable-xxhdpi
folders: https://github.com/googlemaps/android-maps-utils/tree/master/library/src/main/resThe Android resources docs say:
I’m guessing in some cases Android is trying to load the resources at densities other than
xhdpi
orxxhdpi
, and as a result there isn’t a default resource to load, and therefore it throws theResources$NotFoundException
.A counter argument to this theory is that further down the docs also say:
A potential complicating factor is that
Drawable getDrawable (int id)
was deprecated in API level 22, withgetDrawable(int, Theme)
replacing it. There is alsoContextCompat.getDrawable()
in the Android X library.So, perhaps the deprecated implementation isn’t properly handling resource scaling in all cases, even though the Android docs say it should work?
Instead of adding additional PNGs in the default folder which would increase the size of the library, I’m going to try fixing this at first by changing to using
ContextCompat.getDrawable()
.I’ll open a PR with this fix shortly. If this doesn’t fix it, we can add the PNGs in the default resource directory.
Same here in library version 3.4.0, the device is Vivo V21 5G(Android 13)
Fatal Exception: android.content.res.Resources$NotFoundException: Resource ID #0x7f070055 at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:353) at android.content.res.Resources.getDrawableForDensity(Resources.java:1078) at android.content.res.Resources.getDrawable(Resources.java:1018) at android.content.Context.getDrawable(Context.java:810) at androidx.core.content.ContextCompat$Api21Impl.getDrawable(ContextCompat.java:864) at androidx.core.content.ContextCompat.getDrawable(ContextCompat.java:483) at com.google.maps.android.ui.BubbleDrawable.<init>(BubbleDrawable.java:42) at com.google.maps.android.ui.IconGenerator.<init>(IconGenerator.java:60) at com.google.maps.android.clustering.view.DefaultClusterRenderer.<init>(DefaultClusterRenderer.java:141) at com.google.maps.android.clustering.ClusterManager.<init>(ClusterManager.java:80) at com.google.maps.android.clustering.ClusterManager.<init>(ClusterManager.java:72) at pl.dominium.base.util.map.presenter.base.ClusterMapPresenter.onMapReady(ClusterMapPresenter.kt:37) at com.google.android.gms.maps.zzaf.zzb(com.google.android.gms:play-services-maps@@18.1.0:1) at com.google.android.gms.maps.internal.zzar.zza(com.google.android.gms:play-services-maps@@18.1.0:6) at com.google.android.gms.internal.maps.zzb.onTransact(com.google.android.gms:play-services-maps@@18.1.0:3) at android.os.Binder.transact(Binder.java:1184) at fe.c(:com.google.android.gms.dynamite_mapsdynamite@232216044@23.22.16 (190400-0):2) at com.google.maps.api.android.lib6.impl.bg.run(:com.google.android.gms.dynamite_mapsdynamite@232216044@23.22.16 (190400-0):2) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:223) at android.os.Looper.loop(Looper.java:324) at android.app.ActivityThread.main(ActivityThread.java:8486) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1061)
@barbeau can’t think of another workaround for this—the approach to create a
drawable-xxxhdpi
makes sense to me.@seventhmoon this issue happened on production and we are only distributing it in Google Play.
@barbeau @arriolac I have pointed our app’s map library version to 1.3.3. Thank you for the fix!
still receiving this error: Nexus 6 (Android 7.1) OnePlus GM1910 (Android 9)