【发布时间】:2019-08-12 23:03:06
【问题描述】:
在不同设备、不同 android 版本上的总用户中有 0.1% 发生崩溃。
android.content.res.Resources$NotFoundException:
at android.content.res.ResourcesImpl.getValue (ResourcesImpl.java:201)
at android.content.res.MiuiResourcesImpl.getValue (MiuiResourcesImpl.java:95)
at android.content.res.Resources.getValue (Resources.java:1304)
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 androidx.appcompat.view.menu.MenuItemImpl.getIcon (MenuItemImpl.java:505)
at androidx.appcompat.view.menu.ActionMenuItemView.initialize (ActionMenuItemView.java:126)
at androidx.appcompat.widget.ActionMenuPresenter.bindItemView (ActionMenuPresenter.java:207)
at androidx.appcompat.view.menu.BaseMenuPresenter.getItemView (BaseMenuPresenter.java:188)
at androidx.appcompat.widget.ActionMenuPresenter.getItemView (ActionMenuPresenter.java:193)
at androidx.appcompat.widget.ActionMenuPresenter.flagActionItems (ActionMenuPresenter.java:473)
at androidx.appcompat.view.menu.MenuBuilder.flagActionItems (MenuBuilder.java:1182)
at androidx.appcompat.view.menu.BaseMenuPresenter.updateMenuView (BaseMenuPresenter.java:96)
at androidx.appcompat.widget.ActionMenuPresenter.updateMenuView (ActionMenuPresenter.java:226)
at androidx.appcompat.view.menu.MenuBuilder.dispatchPresenterUpdate (MenuBuilder.java:298)
at androidx.appcompat.view.menu.MenuBuilder.onItemsChanged (MenuBuilder.java:1069)
at androidx.appcompat.view.menu.MenuBuilder.startDispatchingItemsChanged (MenuBuilder.java:1096)
at androidx.appcompat.app.AppCompatDelegateImpl.preparePanel (AppCompatDelegateImpl.java:1778)
at androidx.appcompat.app.AppCompatDelegateImpl.doInvalidatePanelMenu (AppCompatDelegateImpl.java:2016)
at androidx.appcompat.app.AppCompatDelegateImpl$2.run (AppCompatDelegateImpl.java:253)
at android.os.Handler.handleCallback (Handler.java:754)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:165)
at android.app.ActivityThread.main (ActivityThread.java:6375)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (Zygo
在菜单创建方法中发生崩溃。 菜单.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_share"
android:icon="@drawable/ic_share"
android:orderInCategory="100"
android:title="share"
app:showAsAction="always" />
</menu>
标准方法:
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menu);
return true;
}
我在可绘制文件夹中有不同的 ic_share.png:nodpi、mdpi、hdpi、xdpi、xxdpi、xxxdpi
我的环境:
- gradle-5.1.1-all.zip
- 类路径'com.android.tools.build:gradle:3.4.2'
- 安卓工作室 3.4.1
- 编译SdkVersion 28
- targetSdkVersion 28
请帮忙。
【问题讨论】:
-
您好,您解决了这个问题吗?我也遇到了同样的问题