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

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

Closed
riryjs opened this issue Sep 26, 2017 · 19 comments · Fixed by #107
Closed

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

riryjs opened this issue Sep 26, 2017 · 19 comments · Fixed by #107

Comments

@riryjs
Copy link

riryjs commented Sep 26, 2017

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.

@vonch
Copy link

vonch commented Sep 28, 2017

I also had the exact same problem

@sxqsfun
Copy link

sxqsfun commented Sep 29, 2017

+1

@litkod
Copy link

litkod commented Sep 29, 2017

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.

@ahmedtehseen
Copy link

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

@ahmedtehseen
Copy link

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

@Balamir
Copy link

Balamir commented Oct 14, 2017

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

Probably, it will be fix.

@euroclydon37
Copy link

euroclydon37 commented Feb 8, 2018

This did not work on Apple TV 4K.

@khadkaPratik
Copy link

khadkaPratik commented Mar 5, 2018

@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

@creativeaura
Copy link

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.

@khadkaPratik
Copy link

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 

@creativeaura
Copy link

@khadkaPratik The fix I mentioned was for Android.

@fedoud32
Copy link

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

@anhdevit
Copy link

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

@edgesinghkataria
Copy link

edgesinghkataria commented Mar 19, 2019

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;

@someoneNameGrey
Copy link

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

@bastienrobert
Copy link

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 ?

@FrederickEngelhardt
Copy link

FrederickEngelhardt commented Apr 14, 2020

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

@alejandropaciotti
Copy link

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"

@16ntu1120
Copy link

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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.