react-native-splash-screen
react-native-splash-screen copied to clipboard
onCreate method does not exist in MainActivity.java
The onCreate method does not exists in MainActivity.java and after creating it as described in documentation, the app wont open and crashes.
What I'm using: "react-native": "0.66.4", "react-native-splash-screen": "^3.3.0",
The Platform: Android
`package com.app;
import android.os.Bundle; import com.facebook.react.ReactActivity;
// react-native-splash-screen >= 0.3.1 import org.devio.rn.splashscreen.SplashScreen;
public class MainActivity extends ReactActivity {
/**
-
Returns the name of the main component registered from JavaScript. This is used to schedule
-
rendering of the component. */ @Override protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(this); // rn splash screen
super.onCreate(savedInstanceState); }
@Override protected String getMainComponentName() { return "Admin"; } }`
Also experiencing this in react-native 0.67.2.
dont know if it will fix your problem but its worth a try. but react-native-screens and react-navigation recommend passing "null" instead of "savedInstanceState" to the onCreate() method. see:
https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067 https://github.com/software-mansion/react-native-screens#android https://reactnavigation.org/docs/getting-started/#installing-dependencies-into-a-bare-react-native-project (v6)
please add this line in MainActivvity.java
import android.os.Bundle;
Had this same problem and @kameshkumar786 's tip did the trick. Thank you!
Had the same issue, followed this and fixed it https://github.com/crazycodeboy/react-native-splash-screen/issues/167#issuecomment-517971996
After creating an splash image through react-native-make, onCreate method will be created.
Save my life @kameshkumar786 ! Show!!!! Work for me: import android.os.Bundle;
if importing import android.os.Bundle doesn't help (because in a fresh-generated RN app it is already there) you can try this #591(comment)
TLDR - onCreate method placed in the nested class, where this points to the entity of a different type, not that SplashScreen.show awaits. But if move onCreate to the top level class in MainActivity file, everything seems to work.
import android.os.Bundle;
inside the Activity class @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... }