带有歌词的Android音乐播放器在重放时崩溃了

时间:2011-07-23 10:33:29

标签: java android

我创建了一个名为" MusicMod"的项目。在Google Code上(基于eliot stocker的Music Mod。)http://code.google.com/p/musicmod/

项目页面上提供了截图

它可以在播放时显示歌词,但在重放时崩溃(有时在k / b拉出时也会崩溃等) 以下是我的错误日志:

W/dalvikvm( 6065): threadid=9: thread exiting with uncaught exception (group=0x400207e8)
E/AndroidRuntime( 6065): FATAL EXCEPTION: Timer-0
E/AndroidRuntime( 6065): java.lang.NullPointerException
E/AndroidRuntime( 6065):    at com.googlecode.musicmod.MediaConnector$1$1.run(MediaConnector.java:65)
E/AndroidRuntime( 6065):    at java.util.Timer$TimerImpl.run(Timer.java:289)
W/ActivityManager(  100):   Force finishing activity com.googlecode.musicmod/.MediaPlaybackActivity
E/ActivityThread( 6065): Activity com.googlecode.musicmod.MediaPlaybackActivity has leaked ServiceConnection com.googlecode.musicmod.MediaConnector$MediaPlayerServiceConnection@43650b18 that was originally bound here
E/ActivityThread( 6065): android.app.ServiceConnectionLeaked: Activity com.googlecode.musicmod.MediaPlaybackActivity has leaked ServiceConnection com.googlecode.musicmod.MediaConnector$MediaPlayerServiceConnection@43650b18 that was originally bound here
E/ActivityThread( 6065):    at android.app.ActivityThread$PackageInfo$ServiceDispatcher.<init>(ActivityThread.java:1121)
E/ActivityThread( 6065):    at android.app.ActivityThread$PackageInfo.getServiceDispatcher(ActivityThread.java:1016)
E/ActivityThread( 6065):    at android.app.ContextImpl.bindService(ContextImpl.java:863)
E/ActivityThread( 6065):    at android.content.ContextWrapper.bindService(ContextWrapper.java:347)
E/ActivityThread( 6065):    at com.googlecode.musicmod.MediaConnector.bindToMusicService(MediaConnector.java:87)
E/ActivityThread( 6065):    at com.googlecode.musicmod.MediaConnector.<init>(MediaConnector.java:48)
E/ActivityThread( 6065):    at com.googlecode.musicmod.MediaPlaybackActivity.onCreate(MediaPlaybackActivity.java:138)
E/ActivityThread( 6065):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/ActivityThread( 6065):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/ActivityThread( 6065):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/ActivityThread( 6065):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/ActivityThread( 6065):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/ActivityThread( 6065):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/ActivityThread( 6065):    at android.os.Looper.loop(Looper.java:123)
E/ActivityThread( 6065):    at android.app.ActivityThread.main(ActivityThread.java:4627)
E/ActivityThread( 6065):    at java.lang.reflect.Method.invokeNative(Native Method)
E/ActivityThread( 6065):    at java.lang.reflect.Method.invoke(Method.java:521)
E/ActivityThread( 6065):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
E/ActivityThread( 6065):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/ActivityThread( 6065):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  100): Unbind failed: could not find connection for android.os.BinderProxy@439c5a70
I/Process ( 6065): Sending signal. PID: 6065 SIG: 9

您还可以在我的项目页面中查看我的源代码。 如果你能解决这个问题,我可以把你当成这个项目的一员。

1 个答案:

答案 0 :(得分:0)

我不确定这一点,但似乎getLyricsContext可能会返回null,并且您不会在MediaConnector的第64-65行检查它。

三个附加的事情:

  1. 当您在堆栈跟踪中看到如下行:com.googlecode.musicmod.MediaConnector$1$1.run(MediaConnector.java:65) $1引用匿名类。 MediaConnector$1$1表示MediaConnector中匿名类中的匿名类。
  2. 你有确切的行,并且你有例外,这一行不应该太难,并检查此时可能为null的内容。
  3. 当您提出问题时,请在下次添加相关代码。如果你付出更多努力并提供更多细节,人们将非常乐意提供帮助。