在某些设备上出现Resources$NotFoundException(设置图标)。

huangapple go评论83阅读模式
英文:

Resources$NotFoundException on some devices (setIcon)

问题

在Google Play商店上,我可以在某些设备(Android 8.0和8.1)上看到以下崩溃日志输出。然而,我无法找出原因,因为日志输出和所有drawable文件夹(hdpi、mdpi、xhdpi、xxhdpi、xxxhdpi)中都缺少潜在的丢失资源ID,并且我有必要的PNG图像。

您知道可能的原因是什么吗?

Caused by: android.content.res.Resources$NotFoundException:
  at android.content.res.ResourcesImpl.getValue (ResourcesImpl.java:215)
  at android.content.res.Resources.getValue (Resources.java:1316)
  at androidx.appcompat.widget.ResourceManagerInternal.createDrawableIfNeeded (ResourceManagerInternal.java:176)
  at androidx.appcompat.widget.ResourceManagerInternal.getDrawable (ResourceManagerInternal.java:141)
  at androidx.appcompat.widget.ResourceManagerInternal.getDrawable (ResourceManagerInternal.java:132)
  at androidx.appcompat.content.res.AppCompatResources.getDrawable (AppCompatResources.java:104)
  at com.google.android.material.tabs.TabLayout$Tab.setIcon (TabLayout.java:1968)
  at com.xyz.myapp.MainActivity.setupTabIcons (MainActivity.java:184)
  at com.xyz.myapp.MainActivity.initialize (MainActivity.java:176)
  at com.xyz.myapp.MainActivity.onRequestPermissionsResult (MainActivity.java:453)
  at android.app.Activity.dispatchRequestPermissionsResult (Activity.java:7429)
  at android.app.Activity.dispatchActivityResult (Activity.java:7280)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4264)

<details>
<summary>英文:</summary>

On Google Play store, I can see below crash log output on certain devices (Android 8.0 and 8.1). However, I&#39;m unable to figure out the reason as a potentially missing resource ID is missing in the log output and in all drawable folders (hdpi, mdpi, xhdpi, xxhdpi, xxxhdpi), I&#39;ve the necessary PNG-images.

Do you have an idea what the reason could be?

Caused by: android.content.res.Resources$NotFoundException:
at android.content.res.ResourcesImpl.getValue (ResourcesImpl.java:215)
at android.content.res.Resources.getValue (Resources.java:1316)
at androidx.appcompat.widget.ResourceManagerInternal.createDrawableIfNeeded (ResourceManagerInternal.java:176)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable (ResourceManagerInternal.java:141)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable (ResourceManagerInternal.java:132)
at androidx.appcompat.content.res.AppCompatResources.getDrawable (AppCompatResources.java:104)
at com.google.android.material.tabs.TabLayout$Tab.setIcon (TabLayout.java:1968)
at com.xyz.myapp.MainActivity.setupTabIcons (MainActivity.java:184)
at com.xyz.myapp.MainActivity.initialize (MainActivity.java:176)
at com.xyz.myapp.MainActivity.onRequestPermissionsResult (MainActivity.java:453)
at android.app.Activity.dispatchRequestPermissionsResult (Activity.java:7429)
at android.app.Activity.dispatchActivityResult (Activity.java:7280)
at android.app.ActivityThread.deliverResults (ActivityThread.java:4264)

答案1

得分: 1

我在切换到应用程序包后开始收到一些此类报告。我一直以为这些报告来自从第三方APK镜像站点下载我的应用程序的用户。因此,如果他们下载的APK与其设备的密度桶不匹配,应用程序会崩溃,因为相关资产根本不存在。

英文:

I started getting a few of these reports after switching to app bundles. I always assumed they were from users who downloaded my apps from third-party APK mirror sites. So if the APK they downloaded doesn't match their device's density bucket, the app crashes as the relevant assets just aren't there.

huangapple
  • 本文由 发表于 2020年8月29日 21:10:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/63647330.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定