yleili
2017-08-07 03:38
采纳率: 100%
浏览 1.5k

Android Media数据库出错

开机启动音乐后,加载上次播放列表,并播放上次记录的音乐,在setDataSource播放的时候出错。Logcat如下:
25.675 E/DatabaseUtils( 695): java.lang.NullPointerException
01-01 02:22:25.675 E/DatabaseUtils( 695): at java.io.File.fixSlashes(File.java:185)
01-01 02:22:25.675 E/DatabaseUtils( 695): at java.io.File.(File.java:134)
01-01 02:22:25.675 E/DatabaseUtils( 695): at com.android.providers.media.MediaProvider.queryForDataFile(MediaProvider.java:4734)
01-01 02:22:25.675 E/DatabaseUtils( 695): at com.android.providers.media.MediaProvider.openFileAndEnforcePathPermissionsHelper(MediaProvider.java:4754)
01-01 02:22:25.675 E/DatabaseUtils( 695): at com.android.providers.media.MediaProvider.openFile(MediaProvider.java:4680)
01-01 02:22:25.675 E/DatabaseUtils( 695): at android.content.ContentProvider.openAssetFile(ContentProvider.java:1213)
01-01 02:22:25.675 E/DatabaseUtils( 695): at android.content.ContentProvider.openTypedAssetFile(ContentProvider.java:1393)
01-01 02:22:25.675 E/DatabaseUtils( 695): at android.content.ContentProvider.openTypedAssetFile(ContentProvider.java:1459)
01-01 02:22:25.675 E/DatabaseUtils( 695): at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:342)
01-01 02:22:25.675 E/DatabaseUtils( 695): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:305)
01-01 02:22:25.675 E/DatabaseUtils( 695): at android.os.Binder.execTransact(Binder.java:404)
01-01 02:22:25.675 E/DatabaseUtils( 695): at dalvik.system.NativeStart.run(Native Method)
01-01 02:22:25.675 E/MediaPlaybackService( 995): mPlayer.setDataSource
01-01 02:22:25.675 W/System.err( 995): java.lang.NullPointerException
01-01 02:22:25.675 W/System.err( 995): at android.os.Parcel.readException(Parcel.java:1471)
01-01 02:22:25.675 W/System.err( 995): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
01-01 02:22:25.675 W/System.err( 995): at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:148)
01-01 02:22:25.675 W/System.err( 995): at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:682)
01-01 02:22:25.675 W/System.err( 995): at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1063)
01-01 02:22:25.675 W/System.err( 995): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:904)
01-01 02:22:25.675 W/System.err( 995): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:831)
01-01 02:22:25.675 W/System.err( 995): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:898)
01-01 02:22:25.675 W/System.err( 995): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:874)
01-01 02:22:25.675 W/System.err( 995): at com.android.newmusic.MediaPlaybackService$MultiPlayer.setDataSourceImpl(MediaPlaybackService.java:2213)
01-01 02:22:25.675 W/System.err( 995): at com.android.newmusic.MediaPlaybackService$MultiPlayer.setDataSource(MediaPlaybackService.java:2200)
01-01 02:22:25.675 W/System.err( 995): at com.android.newmusic.MediaPlaybackService.open(MediaPlaybackService.java:1396)
01-01 02:22:25.675 W/System.err( 995): at com.android.newmusic.MediaPlaybackService.openCurrentAndNext(MediaPlaybackService.java:1280)
01-01 02:22:25.675 W/System.err( 995): at com.android.newmusic.MediaPlaybackService.reloadQueue(MediaPlaybackService.java:700)
01-01 02:22:25.675 W/System.err( 995): at com.android.newmusic.MediaPlaybackService.onCreate(MediaPlaybackService.java:444)
01-01 02:22:25.675 W/System.err( 995): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2558)
01-01 02:22:25.675 W/System.err( 995): at android.app.ActivityThread.access$1800(ActivityThread.java:135)
01-01 02:22:25.675 W/System.err( 995): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
01-01 02:22:25.675 W/System.err( 995): at android.os.Handler.dispatchMessage(Handler.java:102)
01-01 02:22:25.675 W/System.err( 995): at android.os.Looper.loop(Looper.java:136)
01-01 02:22:25.675 W/System.err( 995): at android.app.ActivityThread.main(ActivityThread.java:5001)
01-01 02:22:25.675 W/System.err( 995): at java.lang.reflect.Method.invokeNative(Native Method)
01-01 02:22:25.675 W/System.err( 995): at java.lang.reflect.Method.invoke(Method.java:515)
01-01 02:22:25.675 W/System.err( 995): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:801)
01-01 02:22:25.675 W/System.err( 995): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:617)
01-01 02:22:25.675 W/System.err( 995): at dalvik.system.NativeStart.main(Native Method)
01-01 02:22:25.675 D/MediaPlaybackService( 995): Failed to open file for playback

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 十二月青 2017-08-07 07:04
    已采纳

    MediaPlaybackService.java:2200,MediaProvider.java:4734,看看这两句代码做的什么操作。我一直在用MediaPlay,遇到的最多的就是空指针。方便的话加QQ792686722

    点赞 评论
  • 嘎吱喀吧 2017-08-07 03:45

    如果你的音乐是系统应用并且在系统启动的时候跟Launcher启动时间差不多的话,这时候sdcard不一定是挂载完成的,是不是这方面原因

    点赞 评论

相关推荐 更多相似问题