react-native-youtube icon indicating copy to clipboard operation
react-native-youtube copied to clipboard

Unable to instantiate fragment com.inprogress.reactnativeyoutube.VideoFragment

Open raoneel opened this issue 6 years ago • 9 comments

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

raoneel avatar Aug 30 '18 00:08 raoneel

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

mehulmpt avatar Sep 10 '18 09:09 mehulmpt

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?

vinayvenu avatar Oct 10 '18 05:10 vinayvenu

Same problem here. Any news about the new release?

luispccruz avatar Oct 16 '18 15:10 luispccruz

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

AmolGslab avatar Oct 26 '18 08:10 AmolGslab

Any solution?

tamirrab avatar Apr 01 '19 14:04 tamirrab

Simple but effective solution.

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

ddman avatar Jun 28 '19 14:06 ddman

Simple but effective solution.

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

What file did you change?

phcbarros avatar Aug 07 '19 16:08 phcbarros

Any news?

hamam99 avatar Jul 06 '20 05:07 hamam99

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.

chichilatte avatar Sep 15 '20 16:09 chichilatte