简体   繁体   中英

Android resource not found exception oncreate

So I have my app created and it works fine on my phones that I test with, but bugsnag is showing me that it is crashing for other users. Here is the bugsnag report.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.activity.Menu_dashboard}: android.content.res.Resources$NotFoundException: Resource ID #0x7f0c005c
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2812)
    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4627)
    at android.app.ActivityThread.-wrap19(ActivityThread.java:-1)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1534)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6317)
    at java.lang.reflect.Method.invoke(Method.java:-2)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0c005c
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:210)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2107)
    at android.content.res.Resources.getLayout(Resources.java:1120)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    at com.myapp.activity.Menu_dashboard.onCreate(Menu_dashboard.java:205)
    at android.app.Activity.performCreate(Activity.java:6757)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2704)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2812)
    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4627)
    at android.app.ActivityThread.-wrap19(ActivityThread.java:-1)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1534)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6317)
    at java.lang.reflect.Method.invoke(Method.java:-2)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

So I went to my R.Java and looked for the resource it was talking about 0x7f0c005c , it turns out this is my main xml file for menu_dashboard and it is crashing on this line

setContentView(R.layout.menu_dashboard);

And yes I do have it after super.onCreate(savedInstanceState); and I do have it listed in my manifest, as I seen that was the error on some of the others I looked at.

There isn't anything special on the menu_dashboard , just a google map and a few imageviews, but it mainly seems like it is LG phones screen size
1193x720 it crashes on.

I can't seem to recreate this issue no matter which phone I try it on (even another phone just like the users). I have even went as far as creating multiple layouts with sw300dp , sw330dp , sw480dp , sw600dp , sw720dp thinking that maybe the screen sized mattered. So what could be causing the main xml file to crash for certain users?

There must be some error in your xml files, or may be android studio have gone mad Try following steps if your layout files do not have any issue

  1. Files > Invalidate Caches/Restart...
  2. Build > Clean / Rebuild Project

If above doesn't work try Restarting your Android Studio.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM