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

无人久伴 提交于 2019-12-13 13:08:04

问题


I am facing this problem I don't have any scenario it reported as 20 times: I have the youtube jar as the version number is:

Manifest-Version: 1.0

Name: com/google/android/youtube/player

Specification-Title: YouTube Android Player API

Specification-Version: 1.2.2

Specification-Vendor: Google Inc

Created-By: 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:


This is an internal issue in YouTube player and will be solved in next release, you can track the issue here :

https://issuetracker.google.com/issues/35172585

This Exception occurred if the YoutubePlayer has been released

According to the Youtube SDK documentation on errors:

public static final YouTubePlayer.ErrorReason UNEXPECTED_SERVICE_DISCONNECTION

Playback has been canceled and the player has been released due to an unexpected disconnection from the YouTube API service. Any further calls to this player instance will result in errors, a new player instance must be created to re-enable playback.

So to avoid this exception you have put your calls (like youtubePlayer.loadVideo(), cueVideo(), getCurrentTimeMillis() etc.) in a try catch block and catch the IllegalStateException exception.

To create a new instance of the YoutubePlayer just call the initialize() method in the catch block.

Example:

 if (youtubePlayer != null) {
        try {
            youtubePlayer.loadVideo(videoId);
        } catch (IllegalStateException e) {
            initialize(API_KEY, this);
        }
    }

This is worked well for me



来源:https://stackoverflow.com/questions/44215998/android-os-deadobjectexception-at-com-google-android-youtube-api-jar-client-remo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!