gpt4 book ai didi

java - 资源$NotFoundException MenuItemImpl

转载 作者:行者123 更新时间:2023-11-30 12:03:53 34 4
gpt4 key购买 nike

崩溃发生在不同设备、不同 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

我的环境:

  1. gradle-5.1.1-all.zip
  2. 类路径 'com.android.tools.build:gradle:3.4.2'
  3. 安卓工作室 3.4.1
  4. compileSdkVersion 28
  5. targetSdkVersion 28

请帮忙。

最佳答案

如果它们不是只为一个 sdk 版本设置的,请检查你的 drawable。

关于java - 资源$NotFoundException MenuItemImpl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57417999/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com