react-native-youtube: Android crashing in production: java.lang.IllegalStateException

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!

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 8
  • Comments: 33

Commits related to this issue

Most upvoted comments

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

I solved like this

<YouTube key = {Math.random()}

+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.

@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 😄

I got the same problem when I rotated the phone

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.

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 )

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

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.

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

Same …

Same issue here. Any fixes?