React-native-splash-screen: undefined is not an object on calling hide()

Created on 20 Feb 2017  ·  15Comments  ·  Source: crazycodeboy/react-native-splash-screen

Most helpful comment

Worked! Especifically the link was not adding the package on MainApplication.java you should have a main application like this:

package com.keradgames.leader;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.cboy.rn.splashscreen.SplashScreenReactPackage;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new SplashScreenReactPackage()
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

All 15 comments

Any news on that? I have the same problem

@carlesnunez Do manual installation. It worked.

Worked! Especifically the link was not adding the package on MainApplication.java you should have a main application like this:

package com.keradgames.leader;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.cboy.rn.splashscreen.SplashScreenReactPackage;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new SplashScreenReactPackage()
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

Im still getting this error, I've checked my MainApplication.java file and its exactly as above.

Just chiming in, I get this also when running jest (ie RN tests). There are no errors when running on an emulator/device though

I have it on IOS

me too on Android.
I use RN48.

I followed the manual steps, still having this error. Was there a solution?

In MainApplication.java I have used.
import org.devio.rn.splashscreen.SplashScreenReactPackage;
instead of.
import com.cboy.rn.splashscreen.SplashScreenReactPackage;
it solved my problem.

same problem!!! android

Same issue, iOS

Same issue when running jest

same issue on both android and ios my RN version is 55.4

Hasn't been a commit since Sep 2018. Don't think anyone is supporting this anymore. Too bad.

react-native link react-native-splash-screen
Fixed the issue.

Was this page helpful?
0 / 5 - 0 ratings