英文:
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'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'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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论