我正面临这个问题我没有任何情况报告为20次: 我有youtube jar,因为版本号是:
清单版本:1.0
名称:com / google / android / youtube / player
规范标题:YouTube Android播放器API
规范 - 版本:1.2.2
规范供应商:Google Inc
已创建:1.8.0-google-v7(Google Inc.)
Fatal Exception: java.lang.IllegalStateException: android.os.DeadObjectException
at com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer.x(SourceFile:209)
at hwe.w(SourceFile:305)
at abpk.onTransact(SourceFile:228)
at android.os.Binder.transact(Binder.java:361)
at com.google.android.youtube.player.internal.d$a$a.r(Unknown Source)
at com.google.android.youtube.player.internal.s.h(Unknown Source)
at com.google.android.youtube.player.YouTubePlayerView.e(Unknown Source)
at com.google.android.youtube.player.YouTubeBaseActivity.onSaveInstanceState(Unknown Source)
at android.app.Activity.performSaveInstanceState(Activity.java:1238)
at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1223)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3175)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3234)
at android.app.ActivityThread.access$1100(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1223)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5021)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by android.os.DeadObjectException
at android.os.BinderProxy.transact(Binder.java)
at com.google.android.apps.youtube.embeddedplayer.service.service.jar.IApiPlayerService$Stub$Proxy.k(SourceFile:289)
at com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer.x(SourceFile:207)
at hwe.w(SourceFile:305)
at abpk.onTransact(SourceFile:228)
at android.os.Binder.transact(Binder.java:361)
at com.google.android.youtube.player.internal.d$a$a.r(Unknown Source)
at com.google.android.youtube.player.internal.s.h(Unknown Source)
at com.google.android.youtube.player.YouTubePlayerView.e(Unknown Source)
at com.google.android.youtube.player.YouTubeBaseActivity.onSaveInstanceState(Unknown Source)
at android.app.Activity.performSaveInstanceState(Activity.java:1238)
at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1223)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3175)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3234)
at android.app.ActivityThread.access$1100(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1223)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5021)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(NativeStart.java)
答案 0 :(得分:1)
这是YouTube播放器中的内部问题,将在下一版本中解决, 你可以在这里跟踪问题:
https://issuetracker.google.com/issues/35172585
如果YoutubePlayer已被释放,则会发生此异常
根据Youtube SDK documentation错误:
public static final YouTubePlayer.ErrorReason UNEXPECTED_SERVICE_DISCONNECTION
播放已被取消,播放器因YouTube API服务意外断开而被释放。对此播放器实例的任何进一步调用都将导致错误,必须创建新的播放器实例才能重新启用播放。
所以为了避免这个异常你已经把你的调用(比如youtubePlayer.loadVideo(),cueVideo(),getCurrentTimeMillis()等)放在try catch块中并捕获IllegalStateException异常。
要创建YoutubePlayer的新实例,只需在catch块中调用initialize()方法。
示例:
if (youtubePlayer != null) {
try {
youtubePlayer.loadVideo(videoId);
} catch (IllegalStateException e) {
initialize(API_KEY, this);
}
}
这对我来说效果很好