不幸的是,MusicPlayerApp已停止

时间:2016-06-18 07:33:01

标签: java android listview android-studio android-debugging

请帮助我的应用程序崩溃这是我的logcat

    at java.lang.reflect.Method.invoke(Method.java:372) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
06-18 05:03:10.800 10304-10304/com.example.vikram.musicplayer I/Process: Sending signal. PID: 10304 SIG: 9
06-18 05:03:21.908 11965-11965/com.example.vikram.musicplayer V/Monotype: SetAppTypeFace- try to flip, app = com.example.vikram.musicplayer
06-18 05:03:21.916 11965-11965/com.example.vikram.musicplayer V/Monotype:     Typeface getFontPathFlipFont - systemFont = default#default
06-18 05:03:21.919 11965-11965/com.example.vikram.musicplayer V/Monotype: SetAppTypeFace- try to flip, app = com.example.vikram.musicplayer
06-18 05:03:21.919 11965-11965/com.example.vikram.musicplayer V/Monotype:     Typeface getFontPathFlipFont - systemFont = default#default
06-18 05:03:21.948 11965-11965/com.example.vikram.musicplayer V/Monotype: SetAppTypeFace- try to flip, app = com.example.vikram.musicplayer
06-18 05:03:21.949 11965-11965/com.example.vikram.musicplayer V/Monotype:     Typeface getFontPathFlipFont - systemFont = default#default
06-18 05:03:21.960 11965-11979/com.example.vikram.musicplayer I/art: Ignoring second debugger -- accepting and dropping
06-18 05:03:21.963 11965-11965/com.example.vikram.musicplayer D/AndroidRuntime: Shutting down VM
06-18 05:03:21.964 11965-11965/com.example.vikram.musicplayer E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.example.vikram.musicplayer, PID: 11965
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.vikram.musicplayer/com.example.vikram.musicplayer.MainActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2320)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2380)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1285)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5289)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
         Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
            at android.app.ListActivity.onContentChanged(ListActivity.java:243)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:381)
            at android.app.Activity.setContentView(Activity.java:2195)
            at com.example.vikram.musicplayer.MainActivity.onCreate(MainActivity.java:40)
            at android.app.Activity.performCreate(Activity.java:6018)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2273)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2380) 
            at android.app.ActivityThread.access$800(ActivityThread.java:151) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1285) 
            at android.os.Handler.dispatchMessage(Handler.java:102) 
            at android.os.Looper.loop(Looper.java:135) 
            at android.app.ActivityThread.main(ActivityThread.java:5289) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:372) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
06-18 05:03:24.033 11965-11965/com.example.vikram.musicplayer I/Process: Sending signal. PID: 11965 SIG: 9

1 个答案:

答案 0 :(得分:0)

根据您的logcat,您需要重新定义ListView ID。试试这个 -

<ListView android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

由于您正在使用ListActivity,因此您的xml文件必须在提及ID时指定关键字android。

希望它会有所帮助:)