android.content.res.Resources $ NotFoundException:资源ID#0x7f080087

问题描述

在我发布的android应用中,我经常从Crashlytics收到崩溃报告,但资源编号为#0x7f080087,带有ResourcesNotFound异常。

我已经搜索了特定的资源ID,但找不到任何内容

我的minSDK为21,targetSDK为29。

崩溃报告的范围从Android版本5.1.1-> 10开始,无论是root用户还是非root用户,以及大量设备混合使用时,都会发生崩溃报告。

我无法自己重新创建此问题,这是我最大的问题。我尝试同时运行调试和发布apk,但无法在设备上触发崩溃。

我将不胜感激任何建议,因为这已成为一个大问题。

ChooseMap onCreateView(其余只是单击侦听器),发生错误的地方:

package xxx

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;


import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.firebase.analytics.FirebaseAnalytics;

public class ChooseMap extends Fragment implements View.OnClickListener{
String mode = "Competitive";
private static final String TAG = "ChooseMap";

private BottomNavigationView topNavigationView;

private SharedPreferences mSharedPreferences;
private SharedPreferences.Editor mEditor;

private ImageView cache,cobblestone,dustII,inferno,mirage,nuke,overpass,train,vertigo;
private View v;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,@Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.choose_map,container,false);

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    mEditor = mSharedPreferences.edit();

    //Sets on click listeners on all images of maps
    cache = (ImageView) v.findViewById(R.id.Cache);
    cache.setonClickListener(this);
    cobblestone = (ImageView) v.findViewById(R.id.Cobblestone);
    cobblestone.setonClickListener(this);
    dustII = (ImageView) v.findViewById(R.id.DustII);
    dustII.setonClickListener(this);
    inferno = (ImageView) v.findViewById(R.id.Inferno);
    inferno.setonClickListener(this);
    mirage = (ImageView) v.findViewById(R.id.Mirage);
    mirage.setonClickListener(this);
    nuke = (ImageView) v.findViewById(R.id.Nuke);
    nuke.setonClickListener(this);
    overpass = (ImageView) v.findViewById(R.id.Overpass);
    overpass.setonClickListener(this);
    train = (ImageView) v.findViewById(R.id.Train);
    train.setonClickListener(this);
    vertigo = (ImageView) v.findViewById(R.id.Vertigo);
    vertigo.setonClickListener(this);

    topNavigationView = v.findViewById(R.id.top_bar_navigation);
    topNavigationView.setSelectedItemId(R.id.competitive_menu);
    topNavigationView.setonNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
           switch (menuItem.getItemId()){
               case R.id.arcade_menu:
                   mode = "Arcade";
                   break;
               case R.id.competitive_menu:
                   mode = "Competitive";
                   break;
           }
           return true;
        }
    });

    // Sets toolbar title to following string
    ((MainActivity)getActivity()).getSupportActionBar().setTitle("Choose Map");

    isAdLoaded();

    return v;
}

我得到以下堆栈跟踪;

RuntimeException

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{<package>/<package>.MainActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
   at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2325)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
   at android.app.ActivityThread.access$800(ActivityThread.java:151)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:135)
   at android.app.ActivityThread.main(ActivityThread.java:5254)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

ResourcesNotFound

Caused by android.content.res.Resources$NotFoundException: Resource ID #0x7f080089
   at android.content.res.Resources.getValue(Resources.java:1266)
   at androidx.appcompat.widget.ResourceManagerInternal.loadDrawableFromDelegates(ResourceManagerInternal.java:252)
   at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:139)
   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 com.google.android.material.bottomnavigation.BottomNavigationItemView.initialize(BottomNavigationItemView.java:136)
   at com.google.android.material.bottomnavigation.BottomNavigationMenuView.buildMenuView(BottomNavigationMenuView.java:537)
   at com.google.android.material.bottomnavigation.BottomNavigationPresenter.updateMenuView(BottomNavigationPresenter.java:67)
   at com.google.android.material.bottomnavigation.BottomNavigationView.inflateMenu(BottomNavigationView.java:344)
   at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:226)
   at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:133)
   at java.lang.reflect.Constructor.newInstance(Constructor.java)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
   at android.view.LayoutInflater.createView(LayoutInflater.java:607)
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
   at <package>.ChooseMap.onCreateView(ChooseMap.java:41)
   at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
   at androidx.fragment.app.FragmentManagerImpl.movetoState(FragmentManagerImpl.java:881)
   at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
   at androidx.fragment.app.FragmentManagerImpl.movetoState(FragmentManagerImpl.java:1303)
   at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
   at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
   at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
   at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
   at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
   at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663)
   at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
   at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
   at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
   at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
   at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1236)
   at android.app.Activity.performStart(Activity.java:6006)
   at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2288)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
   at android.app.ActivityThread.access$800(ActivityThread.java:151)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:135)
   at android.app.ActivityThread.main(ActivityThread.java:5254)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)