com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer.x 上的 android.os.DeadObjectException

Posted

技术标签:

【中文标题】com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer.x 上的 android.os.DeadObjectException【英文标题】:android.os.DeadObjectException at com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer.x 【发布时间】:2017-10-28 04:46:38 【问题描述】:

我正面临这个问题,我没有报告 20 次的任何情况: 我有 youtube jar,因为版本号是:

清单版本:1.0

名称:com/google/android/youtube/player

规范-标题:YouTube Android Player 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)

【问题讨论】:

【参考方案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);
        
    

这对我来说效果很好

【讨论】:

以上是关于com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer.x 上的 android.os.DeadObjectException的主要内容,如果未能解决你的问题,请参考以下文章