Skip to content

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

Description

@riryjs

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.

Activity

  1. vonch commented on Sep 28, 2017

    @vonch

    I also had the exact same problem

  2. sxqsfun commented on Sep 29, 2017

    @sxqsfun

    +1

  3. litkod commented on Sep 29, 2017

    @litkod

    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.

  4. ahmedtehseen commented on Oct 1, 2017

    @ahmedtehseen

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

  5. ahmedtehseen commented on Oct 1, 2017

    @ahmedtehseen

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

  6. Balamir commented on Oct 14, 2017

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

    Probably, it will be fix.

  7. euroclydon37 commented on Feb 8, 2018

    @euroclydon37

    This did not work on Apple TV 4K.

  8. khadkaPratik commented on Mar 5, 2018

    @khadkaPratik

    @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

  9. creativeaura commented on Mar 12, 2018

    @creativeaura

    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.

  10. khadkaPratik commented on Mar 18, 2018

    @khadkaPratik

    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 
    
    
  11. creativeaura commented on Mar 18, 2018

    @creativeaura

    @khadkaPratik The fix I mentioned was for Android.

  12. fedoud32 commented on Oct 11, 2018

    @fedoud32

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

  13. anhdevit commented on Nov 23, 2018

    @anhdevit

    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

  14. edgesinghkataria commented on Mar 19, 2019

    @edgesinghkataria

    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;

  15. someoneNameGrey commented on Jul 19, 2019

    @someoneNameGrey

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

  16. bastienrobert commented on Feb 7, 2020

    @bastienrobert

    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 ?

  17. FrederickEngelhardt commented on Apr 14, 2020

    @FrederickEngelhardt

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

  18. alejandropaciotti commented on Oct 27, 2020

    @alejandropaciotti

    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"
    
  19. 16ntu1120 commented on Mar 22, 2021

    @16ntu1120

    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!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions