zoukankan      html  css  js  c++  java
  • 解决 java.lang.RuntimeException: Unable to start activity ComponentInfo{...}

    错误信息:

    E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.example.express_delivery, PID: 22103
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.express_delivery/com.example.express_delivery.sms.HomeActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x0
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3499)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3653)
            at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
            at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:151)
            at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:111)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2224)
            at android.os.Handler.dispatchMessage(Handler.java:107)
            at android.os.Looper.loop(Looper.java:238)
            at android.app.ActivityThread.main(ActivityThread.java:7813)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
         Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
            at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:254)
            at android.content.res.Resources.loadXmlResourceParser(Resources.java:2296)
            at android.content.res.Resources.getLayout(Resources.java:1183)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
            at com.example.express_delivery.sms.PrivacyDialog.<init>(PrivacyDialog.java:50)
            at com.example.express_delivery.sms.HomeActivity.onCreate(HomeActivity.java:77)
            at android.app.Activity.performCreate(Activity.java:7961)
            at android.app.Activity.performCreate(Activity.java:7950)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3474)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3653) 
            at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
            at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:151) 
            at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:111) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2224) 
            at android.os.Handler.dispatchMessage(Handler.java:107) 
            at android.os.Looper.loop(Looper.java:238) 
            at android.app.ActivityThread.main(ActivityThread.java:7813) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995) 

    解决:

    看到图中亮蓝色的字(这个是我们自己代码的错误),然后我就点击了这两个,最后发现下面这个我当初是引用的上边的,所以错误主要在PrivacyDialog.java文件里

    我按提示定位到了错误的地方:

    图中浅黄色的这一行,当时我就纳闷,这个smsdemo_authorize_dialog是什么?

    然后就定位这个方法 getLayoutRes,想找到这个参数是什么

    函数是长这样的,是一个layout的名字,我当时是想可能还有一个layout的xml文件没有添加,然后发现果然是(因为我这个也是参考的demo)

    添加上之后,就不报错了

    完结

  • 相关阅读:
    Vue自定义指令
    Vue实例生命周期
    Vue学习目录
    Vue表单控件绑定
    Vue事件处理
    Vue数组更新及过滤排序
    Vue模板逻辑
    Vue模板内容
    Vue实例对象的数据选项
    Vue组件基础用法
  • 原文地址:https://www.cnblogs.com/022414ls/p/13474217.html
Copyright © 2011-2022 走看看