简体   繁体   English

找不到Android资源oncreate异常

[英]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. 因此,我创建了我的应用程序,并且可以在我测试过的手机上正常运行,但是bugsnag向我展示了该应用程序对其他用户崩溃了。 Here is the bugsnag report. 这是bugsnag报告。

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 所以我去了R.Java,寻找了它在谈论0x7f0c005c的资源,事实证明这是我的menu_dashboard主要xml文件,它在此行崩溃

setContentView(R.layout.menu_dashboard);

And yes I do have it after super.onCreate(savedInstanceState); 是的,在super.onCreate(savedInstanceState);之后,我确实拥有它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 menu_dashboard上没有什么特别的menu_dashboard ,只是谷歌地图和一些图像menu_dashboard ,但主要似乎是LG手机的屏幕尺寸
1193x720 it crashes on. 1193x720它崩溃了。

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. 我什至可以使用sw300dpsw330dpsw480dpsw600dpsw720dp创建多个布局, sw720dp认为屏幕大小很重要。 So what could be causing the main xml file to crash for certain users? 那么,是什么导致某些用户的主要xml文件崩溃?

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 您的xml文件中一定有错误,或者是android studio发疯了如果您的布局文件没有任何问题,请尝试执行以下步骤

  1. Files > Invalidate Caches/Restart... 文件 >使缓存无效/重新启动...
  2. Build > Clean / Rebuild Project 生成 > 清理/重建项目

If above doesn't work try Restarting your Android Studio. 如果上述方法不起作用,请尝试重新启动Android Studio。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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