react-native-youtube icon indicating copy to clipboard operation
react-native-youtube copied to clipboard

Android crashing in production: java.lang.IllegalStateException

Open joncursi opened this issue 8 years ago • 33 comments

I just recently launched my React Native Android app into production and several users are experiencing the following crash:

java.lang.IllegalStateException

screen shot 2017-11-15 at 7 20 04 am

It seems to be coming from the react-native-youtube module. I'm not sure how to go about debugging this. I can't seem to reproduce it locally on any of my physical devices, and because it's Java and not JavaScript, I'm a bit unfamiliar.

If you could help point me in the right direction, I would really appreciate it!

joncursi avatar Nov 15 '17 12:11 joncursi

screen shot 2017-11-24 at 11 37 57 am

App crashes when I slowly scroll down ListView and then slowly try to scroll upto the video and again scroll down to the video.

Logcat show the following error : java.lang.IllegalStateException: This YouTubePlayer has been released

Help'll be appreciated.

Jainesh219 avatar Nov 24 '17 06:11 Jainesh219

+1

adamonkey avatar Nov 27 '17 15:11 adamonkey

i have the same issue

 java.lang.IllegalStateException: This YouTubePlayer has been released

banphlet avatar Feb 02 '18 16:02 banphlet

+1 In my case, the crash is happening when I go to Youtube by tapping the Youtube button and then come back to my app.

saitbnzl avatar Feb 23 '18 14:02 saitbnzl

Same +1

ozanmanav avatar Feb 23 '18 14:02 ozanmanav

Same Error with me. Has anyone found the solution ?

shubz1998 avatar Mar 22 '18 05:03 shubz1998

Same here

judemanutd avatar May 18 '18 19:05 judemanutd

I got the same problem when I rotated the phone

ed828a avatar Jun 06 '18 08:06 ed828a

Is there any update on this? It still happens on my production app.

mehulmpt avatar Sep 09 '18 18:09 mehulmpt

Same issue here. Any fixes?

emil-ep avatar Oct 04 '18 13:10 emil-ep

Same ...

Kisepro avatar Dec 02 '18 21:12 Kisepro

+1

vkumarNobul avatar Dec 13 '18 20:12 vkumarNobul

    --------- beginning of crash
2019-03-01 11:23:23.427 6523-6523/com.allsocial.app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.allsocial.app, PID: 6523
    java.lang.IllegalStateException: This YouTubePlayer has been released
        at hue.a(SourceFile:98)
        at hue.l(SourceFile:227)
        at acye.onTransact(SourceFile:54)
        at android.os.Binder.transact(Binder.java:604)
        at com.google.android.youtube.player.internal.d$a$a.a(Unknown Source:18)
        at com.google.android.youtube.player.internal.s.play(Unknown Source:2)
        at com.inprogress.reactnativeyoutube.YouTubePlayerController$1.run(YouTubePlayerController.java:315)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
    
    
    --------- beginning of system

adamvenord17 avatar Mar 01 '19 09:03 adamvenord17

You can set "resumePlayAndroid" to false to prevent the app to crash. The problem with this solution is, you get a black rectangle instead of a crash.

Here a gist how I solved the problem with "This YouTubePlayer has been released" and Black Screen.

https://gist.github.com/HashDot/e47ad8366d9193901c9c7538276874a2

HashDot avatar Mar 20 '19 13:03 HashDot

@HashDot What version of react-native-youtube are you using? I'm using v1.1.0 and it doesn't work. Work around using YoutubeStandaloneAndroid but it affects a lot of tracking algorithm since your app state change to "background" on play and "active" when it stop.

Khuongnb avatar Jun 19 '19 12:06 Khuongnb

@Khuongnb I use v1.1.0 You can find a more detailed explanation on my blog: https://hashdot.co/blog/react-native-youtube but I need to update the post with some more dirty tricks how I get what I want :D

HashDot avatar Jun 19 '19 12:06 HashDot

You can set "resumePlayAndroid" to false to prevent the app to crash. The problem with this solution is, you get a black rectangle instead of a crash.

Here a gist how I solved the problem with "This YouTubePlayer has been released" and Black Screen.

https://gist.github.com/HashDot/e47ad8366d9193901c9c7538276874a2

this solved my crash problem, but now the video stay as a black space, cant do anything like, play

lefrankleal avatar Aug 08 '19 06:08 lefrankleal

@lefrankleal check out my blog article: https://hashdot.co/blog/react-native-youtube

HashDot avatar Aug 08 '19 09:08 HashDot

@lefrankleal check out my blog article: https://hashdot.co/blog/react-native-youtube

hi @HashDot, i followed your tutorial, but once i come back to the previous screen, the video played for 1 sec then stop, UNAUTHORIZED_OVERLAY error :( any ideas?

neneji avatar Sep 04 '19 11:09 neneji

I also attempted to follow @HashDot tutorial but now it will play for 1second and then stop. It does not crash but it doesn't work either. Has any solved this? If not looks like I'll be using another video player.

code-jenn-or avatar Feb 24 '20 19:02 code-jenn-or

Theres a youtube button that'll open separate youtube app. If youtube app is closed, the app crashes. None of the above solution worked for me. See the details here

bbeckkk avatar Mar 14 '20 04:03 bbeckkk

You can just tweak it with state. have a initial state of loading true, then

componentWillUnmount() { // Remove the event listener this.focusListener(); }

componentDidMount = () => {
   // every time the screen is focus
    this.focusListener = this.props.navigation.addListener('focus', () => {
        this.setState({ loading: true })
        setTimeout(() => {
            this.setState({ loading: false })
        }, 100);
    })
};

in your render function just dont render the YoutubePlayer if the state is loading.

if you want to navigate to other screen just setState({ loading : true}, () => //navigate )

GnApollo avatar Aug 18 '20 12:08 GnApollo

@samulon13 is the loading state you mentioned associated with rendering the component like so?

{!isLoading && <Youtube ... />}

This crashes for me. What are you returning?

psdewar avatar Aug 21 '20 01:08 psdewar

{this.state.loading ? <ActivityIndicator /> : <Youtube ... />}

GnApollo avatar Aug 21 '20 10:08 GnApollo

i also use Backhandler and set the loading to true again when ever the system go back. Because in application the number of navigation to push depends on the number of nodes that was created by the admin.

GnApollo avatar Aug 21 '20 10:08 GnApollo

We had this trouble and fixed it by tweaking android/src/main/java/com/inprogress/reactnativeyoutube/VideoFragment.java. More info here.

Also, to replicate the crash – on the device/simulator i would be on our app, then switch to a memory-hungry webpage that ate up 100s of megs and then switch back to our app.

chichilatte avatar Sep 15 '20 16:09 chichilatte

I solved like this

<YouTube key = {Math.random()}

sangameshrently avatar Nov 09 '20 06:11 sangameshrently

I also attempted to follow @HashDot tutorial but now it will play for 1second and then stop. It does not crash but it doesn't work either. Has any solved this? If not looks like I'll be using another video player.

yes same for me any help or update how you solved

92sajid110 avatar Nov 15 '20 06:11 92sajid110

I solved like this

<YouTube key = {Math.random()}

didn't work unauthorized overlay

92sajid110 avatar Nov 15 '20 06:11 92sajid110

I still get this error.

The error almost never occurs in debug mode. It occurs more often when attached to the metro serverwith debug off, It occurs a lot of the time in production builds, virtually always on first load.

Setting resumePlayAndroid to false results in a black screen instead of a crash. This is a little better but not much.

kongen84 avatar Dec 14 '20 11:12 kongen84