Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to instantiate fragment com.inprogress.reactnativeyoutube.VideoFragment #312

Open
raoneel opened this issue Aug 30, 2018 · 9 comments

Comments

@raoneel
Copy link

raoneel commented Aug 30, 2018

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: []
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at java.lang.Class.getConstructor0(Class.java:2320)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at java.lang.Class.getConstructor(Class.java:1725)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: at android.app.Fragment.instantiate(Fragment.java:520)
07-26 11:05:33.372 32113 32113 E AndroidRuntime: ... 19 more
07-26 11:05:33.372 32113 32135 D libEGL : loaded /vendor/lib/egl/libGLESv1_CM_adreno.so

@mehulmpt
Copy link

+1 Having same issue on others' phones sometimes on production build

@vinayvenu
Copy link

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?

@luispccruz
Copy link

Same problem here. Any news about the new release?

@AmolGslab
Copy link

AmolGslab commented Oct 26, 2018

Same problem here.
Is it ok to just copy paste "public VideoFragment() {}" in package file of 1.1.0?

@tamirrab
Copy link

tamirrab commented Apr 1, 2019

Any solution?

@ddman
Copy link

ddman commented Jun 28, 2019

Simple but effective solution.

// super.onCreate(savedInstanceState);
super.onCreate(null);

@phcbarros
Copy link

Simple but effective solution.

// super.onCreate(savedInstanceState);
super.onCreate(null);

What file did you change?

@hamam99
Copy link

hamam99 commented Jul 6, 2020

Any news?

chichilatte added a commit to chichilatte/react-native-youtube that referenced this issue Sep 15, 2020
darriuk added a commit to darriuk/react-native-youtube that referenced this issue Sep 15, 2020
Bugfix for issue davidohayon669#312 & davidohayon669#238: "Unable to instantiate fragment..."
@chichilatte
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants