Android错误:java.lang.RuntimeException: Unable to start activity ComponentInfo

调试时的错误信息是这样的,

E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.spacesoftwares.myapplication3, PID: 11240
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.spacesoftwares.myapplication3/com.spacesoftwares.myapplication3.MyRecyclerView.LinearRecyclerViewActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.v7.app.AlertController.RecycleListView
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
  at android.app.ActivityThread.-wrap12(ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:154)
  at android.app.ActivityThread.main(ActivityThread.java:6077)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
                   Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.v7.app.AlertController.RecycleListView
                   Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class android.support.v7.app.AlertController.RecycleListView
                   Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AlertController.RecycleListView" on path: DexPathList[[zip file "/data/app/com.spacesoftwares.myapplication3-2/base.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.spacesoftwares.myapplication3-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.spacesoftwares.myapplication3-2/lib/x86_64, /system/lib64, /vendor/lib64]]
  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
  at android.view.LayoutInflater.createView(LayoutInflater.java:609)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
  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.spacesoftwares.myapplication3.MyRecyclerView.LinearRecyclerViewActivity.onCreate(LinearRecyclerViewActivity.java:16)
  at android.app.Activity.performCreate(Activity.java:6662)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
E/AndroidRuntime:     at android.app.ActivityThread.-wrap12(ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:154)
  at android.app.ActivityThread.main(ActivityThread.java:6077)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

自己找了下原因,发现是原本某个该写RecyclerView的地方,写成了RecyclerListView。嗯, 这里记录下做处备忘录吧。

在网上找了一圈,发现该问题大体都是系统加载时因不能分辨布局文件而导致的运行时异常,有以下几类问题可能引发这个错误:

1.xml布局文件组件写的不对,如标签结束不对,<imageView>标签的结束不对,大小写弄错,组件名称弄错;

2.setContentView()中指定的布局对象不能正确链接,或布局文件是一个引用,而该引用或许存在错误;

3.引用的资源未初始化,或找不到资源;或者view中引用的图片的尺寸太大,设备无法识别,出现运行时异常。

posted @ 2018-07-17 15:08  SpaceVision  阅读(195)  评论(0编辑  收藏  举报