不幸的是,MyApp已经停止了

时间:2016-05-19 08:53:33

标签: android

当我在模拟器中运行MyApp时,安装然后我登录到第一页后不幸地显示,MyApp已停止... 如何克服这个错误?

这是在Logcat中显示...

05-19 04:46:59.538 4109-4109/com.example.bharathi.m_box W/System: ClassLoader referenced unknown path: /data/app/com.example.bharathi.m_box-2/lib/x86
05-19 04:46:59.926 4109-4109/com.example.bharathi.m_box W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
05-19 04:47:00.000 4109-4109/com.example.bharathi.m_box I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
05-19 04:47:00.003 4109-4109/com.example.bharathi.m_box I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
05-19 04:47:00.099 4109-4140/com.example.bharathi.m_box D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[ 05-19 04:47:00.108  4109: 4109 D/         ]
HostConnection::get() New Host Connection established 0xe9891ce0, tid 4109
05-19 04:47:00.196 4109-4140/com.example.bharathi.m_box D/libEGL: loaded /system/lib/egl/libEGL_emulation.so
05-19 04:47:00.197 4109-4140/com.example.bharathi.m_box D/libEGL: loaded /system/lib/egl/libGLESv1_CM_emulation.so
05-19 04:47:00.208 4109-4140/com.example.bharathi.m_box D/libEGL: loaded /system/lib/egl/libGLESv2_emulation.so
[ 05-19 04:47:00.233  4109: 4140 D/         ]
HostConnection::get() New Host Connection established 0xeea92750, tid 4140
05-19 04:47:00.275 4109-4140/com.example.bharathi.m_box I/OpenGLRenderer: Initialized EGL, version 1.4
05-19 04:47:00.396 4109-4140/com.example.bharathi.m_box W/EGL_emulation: eglSurfaceAttrib not implemented
05-19 04:47:00.396 4109-4140/com.example.bharathi.m_box W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xeea93560, error=EGL_SUCCESS
05-19 04:47:00.649 4109-4109/com.example.bharathi.m_box I/Choreographer: Skipped 30 frames!  The application may be doing too much work on its main thread.
05-19 04:47:01.196 4109-4109/com.example.bharathi.m_box I/Choreographer: Skipped 31 frames!  The application may be doing too much work on its main thread.
05-19 04:47:11.633 4109-4109/com.example.bharathi.m_box D/AndroidRuntime: Shutting down VM


--------- beginning of crash
05-19 04:47:11.633 4109-4109/com.example.bharathi.m_box E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.bharathi.m_box, PID: 4109
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bharathi.m_box/com.example.bharathi.m_box.MainActivity}: java.lang.ClassCastException: android.support.v7.widget.RecyclerView cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassCastException: android.support.v7.widget.RecyclerView cannot be cast to android.widget.ListView
at com.example.bharathi.m_box.MainActivity.onCreate(MainActivity.java:41)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
05-19 04:47:15.455 4109-4109/com.example.bharathi.m_box I/Process: Sending signal. PID: 4109 SIG: 9

2 个答案:

答案 0 :(得分:1)

在您的布局中,您使用的是其他视图,而不是您想要的

android.support.v7.widget.RecyclerView cannot be cast to android.widget.ListView

因此,您应该决定是使用ListView还是RecyclerView以及与之相关的所有内容。 AdaptersViewHolder

了解更多here(ListView)here(RecyclerView)

答案 1 :(得分:1)

你某处有一个null指针。