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!

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.
+1
i have the same issue
java.lang.IllegalStateException: This YouTubePlayer has been released
+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.
Same +1
Same Error with me. Has anyone found the solution ?
Same here
I got the same problem when I rotated the phone
Is there any update on this? It still happens on my production app.
Same issue here. Any fixes?
Same ...
+1
--------- 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
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 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 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
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 check out my blog article: https://hashdot.co/blog/react-native-youtube
@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?
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.
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
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 )
@samulon13 is the loading state you mentioned associated with rendering the component like so?
{!isLoading && <Youtube ... />}
This crashes for me. What are you returning?
{this.state.loading ? <ActivityIndicator /> : <Youtube ... />}
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.
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.
I solved like this
<YouTube key = {Math.random()}
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
I solved like this
<YouTube key = {Math.random()}
didn't work unauthorized overlay
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.