【问题标题】:Resources$NotFoundException on some devices (setIcon)某些设备上的 Resources$NotFoundException (setIcon)
【发布时间】:2020-08-29 21:18:28
【问题描述】:

在 Google Play 商店中,我可以在某些设备(Android 8.0 和 8.1)上看到以下崩溃日志输出。但是,我无法找出原因,因为日志输出和所有可绘制文件夹(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)

【问题讨论】:

    标签: java android android-drawable android-resources android-tablayout


    【解决方案1】:

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

    【讨论】:

    • 感谢您的提示!这似乎确实是解决方案,因为我还使用模拟器测试了受影响的设备,绝对找不到任何问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-11
    • 1970-01-01
    • 2019-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-21
    相关资源
    最近更新 更多