react-native-youtube
react-native-youtube copied to clipboard
Unable to instantiate fragment com.inprogress.reactnativeyoutube.VideoFragment
I get this error (only sometimes) when I'm launching my app. Seems to happen about 1/10 times after launching the app on Android.
07-26 11:05:33.372 32113 32113 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.inprogress.reactnativeyoutube.VideoFragment: could not find Fragment constructor
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.ActivityThread.-wrap11(Unknown Source:0)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6494)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.inprogress.reactnativeyoutube.VideoFragment: could not find Fragment constructor
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.Fragment.instantiate(Fragment.java:539)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.FragmentContainer.instantiate(FragmentContainer.java:49)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.FragmentState.instantiate(FragmentState.java:77)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:2843)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.FragmentController.restoreAllState(FragmentController.java:136)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.Activity.onCreate(Activity.java:1011)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:51)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7009)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7000)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: ... 9 more
07-26 11:05:33.372 32113 32113 E AndroidRuntime: Caused by: java.lang.NoSuchMethodException:
+1 Having same issue on others' phones sometimes on production build
It seems like the latest version (1.1.1) does not have a default constructor (https://github.com/inProgress-team/react-native-youtube/blob/v1.1.0/android/src/main/java/com/inprogress/reactnativeyoutube/VideoFragment.java), but master has it (https://github.com/inProgress-team/react-native-youtube/blob/master/android/src/main/java/com/inprogress/reactnativeyoutube/VideoFragment.java).
When do we expect a new release?
Same problem here. Any news about the new release?
Same problem here. Is it ok to just copy paste "public VideoFragment() {}" in package file of 1.1.0?
Any solution?
Simple but effective solution.
// super.onCreate(savedInstanceState);
super.onCreate(null);
Simple but effective solution.
// super.onCreate(savedInstanceState);
super.onCreate(null);
What file did you change?
Any news?
I can confirm that @vinayvenu's suggested changes to VideoFragment.java
does the trick 🚀
We forked the original repo on github, tweaked it and used that forked repo in our project's package.json
file, like this...
"dependencies": {
...
"react-native-youtube": "darriuk/react-native-youtube#v1.1.1",
...
}
Miraculously, yarn knows to grab that from github.
Note: You probably don't want to use our repo unless you want to use v1 of the react-native-youtube module.