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

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
- Merge pull request #1 from chichilatte/v1.1.1 Bugfix for issue #312 & #238: "Unable to instantiate fragment..." — committed to darriuk/react-native-youtube by darriuk 4 years ago
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
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(); }
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.
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?