We use Android Youtube API in out application. Lately I noticed that application crashes every time I try to play a video with enabled ads.
I'm able to reproduce it using their sample applications. I've tried SimplePlayerFragment and SimplePlayerView examples. Both crash when I try to cue the http://www.youtube.com/watch?v=QudbrUcVPxk video (this is just an example, other videos with ads are failing too).
Here is LogCat output:
10-26 19:10:49.074: E/AndroidRuntime(21637): FATAL EXCEPTION: main 10-26 19:10:49.074: E/AndroidRuntime(21637): java.lang.IllegalStateException: android.os.DeadObjectException 10-26 19:10:49.074: E/AndroidRuntime(21637): at com.google.android.apps.youtube.api.jar.a.eo.surfaceDestroyed(SourceFile:236) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.view.SurfaceView.updateWindow(SurfaceView.java:555) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:232) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.view.View.dispatchDetachedFromWindow(View.java:12156) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2565) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2565) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3785) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3758) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.view.ViewGroup.removeView(ViewGroup.java:3690) 10-26 19:10:49.074: E/AndroidRuntime(21637): at com.google.android.youtube.player.YouTubePlayerView$1.b(Unknown Source) 10-26 19:10:49.074: E/AndroidRuntime(21637): at com.google.android.youtube.player.internal.r.h(Unknown Source) 10-26 19:10:49.074: E/AndroidRuntime(21637): at com.google.android.youtube.player.internal.r$e.onServiceDisconnected(Unknown Source) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.app.LoadedApk$ServiceDispatcher.doDeath(LoadedApk.java:1111) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1125) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.os.Handler.handleCallback(Handler.java:730) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.os.Handler.dispatchMessage(Handler.java:92) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.os.Looper.loop(Looper.java:137) 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.app.ActivityThread.main(ActivityThread.java:5103) 10-26 19:10:49.074: E/AndroidRuntime(21637): at java.lang.reflect.Method.invokeNative(Native Method) 10-26 19:10:49.074: E/AndroidRuntime(21637): at java.lang.reflect.Method.invoke(Method.java:525) 10-26 19:10:49.074: E/AndroidRuntime(21637): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 10-26 19:10:49.074: E/AndroidRuntime(21637): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-26 19:10:49.074: E/AndroidRuntime(21637): at dalvik.system.NativeStart.main(Native Method) 10-26 19:10:49.074: E/AndroidRuntime(21637): Caused by: android.os.DeadObjectException 10-26 19:10:49.074: E/AndroidRuntime(21637): at android.os.BinderProxy.transact(Native Method) 10-26 19:10:49.074: E/AndroidRuntime(21637): at com.google.android.apps.youtube.api.b.a.be.a(SourceFile:221) 10-26 19:10:49.074: E/AndroidRuntime(21637): at com.google.android.apps.youtube.api.jar.a.eo.surfaceDestroyed(SourceFile:233) 10-26 19:10:49.074: E/AndroidRuntime(21637): ... 22 more
I'd appreciate any ideas on how to solve the problem.
UPD:
Thanks to @septagon, found another related LogCat message:
10-27 16:58:51.763: D/YouTubeAndroidPlayerAPI(25196): apps.youtube.core.client.DefaultAdStatsClient.a:485 Pinging __AWCl-JGAkAHIAQWpAn4krwpwE7A-4AIAqAMBmAQFqgSwAU_QADdeVEnDazwBrSnaYs3R1HBqy45Cu537TEJ3YTBlvSni0sRdoz7KdLcSM8GN-htn40LlHEa78Q0Wc-Hrk04QcefoGDWqXcyn7fC6U9J6CfOz_J6n509CB7hJfQX2xrj2YTLwO2_AeK-bj9k3KWULoKQv_ZBYw5PfzGYPi2xuSOmQuuFoYcr0atVp-oLKiFDMrNiGhAsjaCbg8jlG43cEZZZ-VSGq1f9Oz1b-XQKw4AQBiAXhiftBkgUGCAMQARgBkgUGCAQQBRgKkgUGCAQQARgBkgUGCAYQARgBkgUECAYYA5AGAaAGHNgGAoAHuaXfLA&sigh=PjCzMkHYDKo&cid=5Gi9PCMcr3WKhFJWqILtjrdq&template_id=213">http://pubads.g.doubleclick.net/pagead/adview?ai=Cr6PgkatsUt7LE8GpmgXc3oHwBbGx9t8DsZHlu3Kx0vmLARABIOP7kwNQ4vr5ivj___AWCl-JGAkAHIAQWpAn4krwpwE7A-4AIAqAMBmAQFqgSwAU_QADdeVEnDazwBrSnaYs3R1HBqy45Cu537TEJ3YTBlvSni0sRdoz7KdLcSM8GN-htn40LlHEa78Q0Wc-Hrk04QcefoGDWqXcyn7fC6U9J6CfOz_J6n509CB7hJfQX2xrj2YTLwO2_AeK-bj9k3KWULoKQv_ZBYw5PfzGYPi2xuSOmQuuFoYcr0atVp-oLKiFDMrNiGhAsjaCbg8jlG43cEZZZ-VSGq1f9Oz1b-XQKw4AQBiAXhiftBkgUGCAMQARgBkgUGCAQQBRgKkgUGCAQQARgBkgUGCAYQARgBkgUECAYYA5AGAaAGHNgGAoAHuaXfLA&sigh=PjCzMkHYDKo&cid=5Gi9PCMcr3WKhFJWqILtjrdq&template_id=213 10-27 16:58:51.763: D/AndroidRuntime(25196): Shutting down VM 10-27 16:58:51.763: W/dalvikvm(25196): threadid=1: thread exiting with uncaught exception (group=0x4158d700) 10-27 16:58:51.773: E/AndroidRuntime(25196): FATAL EXCEPTION: main 10-27 16:58:51.773: E/AndroidRuntime(25196): java.lang.NullPointerException 10-27 16:58:51.773: E/AndroidRuntime(25196): at com.google.android.apps.youtube.core.player.AdStatsMacros.a(SourceFile:185) 10-27 16:58:51.773: E/AndroidRuntime(25196): at com.google.android.apps.youtube.core.client.DefaultAdStatsClient.a(SourceFile:481) 10-27 16:58:51.773: E/AndroidRuntime(25196): at com.google.android.apps.youtube.core.client.DefaultAdStatsClient.a(SourceFile:467) 10-27 16:58:51.773: E/AndroidRuntime(25196): at com.google.android.apps.youtube.core.client.DefaultAdStatsClient.a(SourceFile:461) 10-27 16:58:51.773: E/AndroidRuntime(25196): at com.google.android.apps.youtube.core.client.DefaultAdStatsClient.h(SourceFile:320) 10-27 16:58:51.773: E/AndroidRuntime(25196): at com.google.android.apps.youtube.core.player.StatsTracker.g(SourceFile:409) 10-27 16:58:51.773: E/AndroidRuntime(25196): at com.google.android.apps.youtube.core.player.an.handleMessage(SourceFile:1615) 10-27 16:58:51.773: E/AndroidRuntime(25196): at android.os.Handler.dispatchMessage(Handler.java:95) 10-27 16:58:51.773: E/AndroidRuntime(25196): at android.os.Looper.loop(Looper.java:137) 10-27 16:58:51.773: E/AndroidRuntime(25196): at android.app.ActivityThread.main(ActivityThread.java:5103) 10-27 16:58:51.773: E/AndroidRuntime(25196): at java.lang.reflect.Method.invokeNative(Native Method) 10-27 16:58:51.773: E/AndroidRuntime(25196): at java.lang.reflect.Method.invoke(Method.java:525) 10-27 16:58:51.773: E/AndroidRuntime(25196): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 10-27 16:58:51.773: E/AndroidRuntime(25196): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-27 16:58:51.773: E/AndroidRuntime(25196): at dalvik.system.NativeStart.main(Native Method)
There is bug filed in public issue tracker.
You can track the progress from there.
Bug is also filed internally.
I encounter the same problem too using my Galaxy S4 with the latest version of youtube. I tried it on my Gnex which does not have the most recent version of youtube and of course everything works fine. seems like the last update made a mess.
Is there any other way to get their attention? is there a way to remove the latest update (just for now, to continue with the development) ?
And for a different topic, have you tried the getCurrentTimeMillis method more than once a second? do you get different time stamps or just the same when you call it more than once a second (say once every 100ms) ?
Thanks, Roy
Check your unfiltered logcat for a NullPointerException
coming from com.google.android.apps.youtube.core.player.AdStatsMacros
. If you can find such an error, you're probably having the same problem as I and this question are experiencing.
Youtube Player API android crashes on playback on some devices
I can confirm that this error has been introduced within the last seventy-two hours and caused a flawlessly-working app to crash whenever an ad tries to play. The error appears to be coming from deep inside the YouTube Player API jar. Nothing seems to be confirmed yet, but it looks like YouTube is trying something new on their API back-end and having some troubles.
来源:https://stackoverflow.com/questions/19604684/youtube-player-for-android-crashes-on-ads-playback