react-native-splash-screen icon indicating copy to clipboard operation
react-native-splash-screen copied to clipboard

undefined is not an object (evaluating '_reactNativeSplashScreen2.default.hide')

Open riryjs opened this issue 9 years ago • 19 comments

I have already configure my code just like the instruction to use the splash screen but when I compile it using my Redmi Note 3 it returns error like this:

image

in line of code:

class Main extends Component {
  constructor(props) {
    super(props);
    this._onPressLogo = this._onPressLogo.bind(this);
 
  componentDidMount() {      
    SplashScreen.hide();  //ERROR here
  }
  _onPressLogo() {
    //this
    Actions.about();
  }
  render() {
    return (
      <Image style={{ flex: 1, width: null }} source={bg}>
        {/* <AndroidBackButton /> */}
        <StatusBar backgroundColor="#114D44" />
        <View style={{ flex: 1, padding: 15 }}>
          <View style={{ flex: 2, justifyContent: 'center', alignItems: 'center' }}>
            {/* <TouchableHighlight onPress={this._onPressLogo} > */}
              <Image source={logo} />
            {/* //</TouchableHighlight>*/}
          </View>
        </View>
      </Image>
    );
  }
}

react-native: "0.48.4" react-native-splash-screen: "^3.0.1" node: v6.11.2 npm: 5.3.0

please tell me how to handle this case.

riryjs avatar Sep 26 '17 04:09 riryjs

I also had the exact same problem

vonch avatar Sep 28 '17 18:09 vonch

+1

sxqsfun avatar Sep 29 '17 04:09 sxqsfun

Do check the android/app/src/main/java/com/appname/MainActivity.java

package com.testapp;

import android.os.Bundle; // I missed out this line
import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen; // According to the instruction, you would just need to use one of the imports, depending on the react-native-splash-screen version.

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 String getMainComponentName() {
        return "TestApp";
    }
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this);
        super.onCreate(savedInstanceState);
    }
}

I screwed up the previous project so badly so I recreated a new project, it worked after I sort out the MainActivity.java.

litkod avatar Sep 29 '17 08:09 litkod

any solution regarding this problem, I also have the same problem.

ahmedtehseen avatar Oct 01 '17 09:10 ahmedtehseen

please take look at this issue #30 you possibly get help from there.

ahmedtehseen avatar Oct 01 '17 10:10 ahmedtehseen

  • Insert #import "SplashScreen.h" to ./ios/<AppName>/AppDelegate.m if not exists
  • Rebuild

Probably, it will be fix.

Balamir avatar Oct 14 '17 23:10 Balamir

This did not work on Apple TV 4K.

euroclydon37 avatar Feb 08 '18 20:02 euroclydon37

@Balamir Hello sir, I have follower the exact same thing mentioned in this Splash Screen Tutorial but I am getting the exact same error mentioned above in my ios devices. I also cleaned the cache and rebuild the project several times but still it didn't work

khadkaPratik avatar Mar 05 '18 05:03 khadkaPratik

You are missing some java code either in MainActivity.java or MainApplication.java.

Make sure you have

new SplashScreenReactPackage()

inside the MainApplication.java otherwise SplashScreen will not be exposed to react code.

I had the same issue adding new SplashScreenReactPackage() fixed it.

creativeaura avatar Mar 12 '18 12:03 creativeaura

Hello @creativeaura I have already fixed the error which I was getting in my application reguarding the splash screen by following some extra steps


1.  I mentioned the LaunchScreen.xib file in Lunch Screen File 
2. Also I added link manually in build setting > Header Search Path > $(SRCROOT)/../node_modules/react-native-splash-screen/ios
3. I dragged react-native-splash-screen/ios/SplashScreen.xcodeproj/ to my project library manually .
4. Dragged libSplashScreen.a from SplashScreen.xcodeproj to Project General Tab > Linked Frameworks and Libraries and dropped it some where with the library 
5. Command + Shift + K and Command +R 

khadkaPratik avatar Mar 18 '18 05:03 khadkaPratik

@khadkaPratik The fix I mentioned was for Android.

creativeaura avatar Mar 18 '18 21:03 creativeaura

please help i have the same issue and all my files are correct

fedoud32 avatar Oct 11 '18 00:10 fedoud32

If someone give error like this in iOS can fix by the way When you link manually in build setting > Header Search Path > $(SRCROOT)/../node_modules/react-native-splash-screen/ios set recursive Hope help you

anhdevit avatar Nov 23 '18 02:11 anhdevit

Make sure you add below lines in MainApplication.java

protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new SvgPackage(),
            new VectorIconsPackage(),
            new SplashScreenReactPackage() //here
          
      );
    }

This will fix the issue!!!

Also make sure you have imported the below package import org.devio.rn.splashscreen.SplashScreenReactPackage;

edgesinghkataria avatar Mar 19 '19 06:03 edgesinghkataria

for iOS developer, try to remove libSplashScreen.a from [Project Name -> build Phases -> Link Binary With Libraries ]. Hope it helps

someoneNameGrey avatar Jul 19 '19 10:07 someoneNameGrey

Same issue with iOS 13.1, RN 0.61.5 and this package using 3.2.0. @anhdevit and @someoneNameGrey answers sadly didn't help 🙁 Is this package still maintains ?

bastienrobert avatar Feb 07 '20 11:02 bastienrobert

for (ios) Remember to cd ios && pod install

FrederickEngelhardt avatar Apr 14 '20 10:04 FrederickEngelhardt

I know this issue is closed, but if someone came here hopelessly I found a simple solution:

In the file ios/<yourAppName>/AppDelegate.m add:

#import "RNSplashScreen.h"

alejandropaciotti avatar Oct 27 '20 23:10 alejandropaciotti

I found solution in my case. Auto linking for this package does not work even if you are using the latest version of react native. Go for the manual linking. Thanks!!

16ntu1120 avatar Mar 22 '21 09:03 16ntu1120