React-native-splash-screen: not work at react-native 0.61.4

Created on 6 Nov 2019  ·  16Comments  ·  Source: crazycodeboy/react-native-splash-screen

Run react-native info in your project and share the content.
React Native Environment Info:
System:
OS: Windows 10
CPU: (20) x64 Intel(R) Xeon(R) CPU E5-2660 v2 @ 2.20GHz
Memory: 3.98 GB / 15.93 GB
Binaries:
Yarn: 1.19.1 - C:Users\Administrator.SC-201910230934\AppData\Roamingnpm\yarn.CMD
npm: 6.12.0 - C:\Program Filesnodejsnpm.CMD
What react-native-splash-screen version are you using?
3.2.0
What platform does your issue occur on? (Android/iOS/Both)
Android
Describe your issue as precisely as possible :
The react-native 0.61.4 migrates onCreate function to MainApplication.java。
Show us the code you are using?

MainApplication.java:

import org.devio.rn.splashscreen.SplashScreenReactPackage; //<--添加这一句
import org.devio.rn.splashscreen.SplashScreen;//<--添加这一句
import android.os.Bundle; // <--添加这一句
@Override
protected List getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List packages = new PackageList(this).getPackages();
packages.add(new SplashScreenReactPackage());//<--添加这一句

      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      return packages;
    }

@Override
public void onCreate() {
super.onCreate();
SplashScreen.show(this);//<--添加这一句
SoLoader.init(this, false);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
}

Most helpful comment

Use this package, way better, just saying to increment its visibility (it's not mine) because I believe that the good work, and the effort that it requires, must be paid off somehow :)

https://github.com/zoontek/react-native-bootsplash

All 16 comments

Use this package, way better, just saying to increment its visibility (it's not mine) because I believe that the good work, and the effort that it requires, must be paid off somehow :)

https://github.com/zoontek/react-native-bootsplash

react-native-splashscreen works for me with 0.61.4.

You have to follow the readme:

  • install package
  • add the onCreate() method to MainActivity.java
  • add launch_screen.xml with your logo
  • call SplashScreen.hide() somewhere in your componentDidMount()
    and thats it

Wow two downvotes... people, I ask, do you wanna solve problems or do you want just to rage against someone who is just trying to help?
Bootsplash works for me on rn 0.61.4.
@TrueTiem When you say that something don't works, say why and at this point I'd say to report it directly on that repo

I adviced that packages for other reasons that brought me to believe that it's better than this one

@edy sorry, did I say something wrong advising another package instead of this one that seems abandoned?

this issue is to solve a problem with this package, not promoting other packages

oh good, so instead of promoting the right one, we should keep using the broken ones.
Clearly I didn't know that in 0.61.4 it's still working considering that the last commit was in April and that a lot of people (the author of this and the other 4 guys that liked the first comment plus many other issues) reported the packages as broken.

He is right though. This package seems to be dead.

Edit: and the recommended package works like a charm. Recommended +1

one more tip. if you have done all configuration on iOS and you still see the old splash screen, remove the app on the simulator and build again.

Wow two downvotes... people, I ask, do you wanna solve problems or do you want just to rage against someone who is just trying to help?
Bootsplash works for me on rn 0.61.4.
@TrueTiem When you say that something don't works, say why and at this point I'd say to report it directly on that repo

I adviced that packages for other reasons that brought me to believe that it's better than this one

@edy sorry, did I say something wrong advising another package instead of this one that seems abandoned?

thank you ! it works!!

For those suffering from androidX migration. I've been there and here's how I made it work.
First convert the android.support to its androidx equivalent in SplashActivity.java.
import androidx.appcompat.app.AppCompatActivity;
instead of :
import android.support.v7.app.AppCompatActivity;

and remove the link from the following files:

  • 'MainApplication.java',

  • 'setting.gradle'

  • 'app/build.gradle'.

Hope this will help you as well. Cheers
Btw I'm using "react-native": "^0.62.0-rc.1",

Hi there,
I'm using "react-native": "0.61.5" and "react-native-splash-screen": "3.2.0"

I was hitting error on app launch (using react-native run-android --variant=release) with all the correct setup following guidelines, however it only happen on certain devices, and the app will be successfully launched after launching it multiple times

below are the errors i got using adb logcat :

AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
AndroidRuntime: Process: com.mta, PID: 6499
AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.WindowInsets.getSystemWindowInsetTop()' on a null object reference

anyone experienced it and i would appreciate for any input

**
i found that if only i had removed these lines from MainActivity.java then everything will work fine, but the 2nd layer of launch screen of cause won't appear.

@Override
  protected void onCreate(Bundle savedInstanceState) {
    SplashScreen.show(this);
    super.onCreate(savedInstanceState);
  }

I was just doing some googling regarding this error as I am experiencing it too

ava.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.WindowInsets.getSystemWindowInsetTop()' on a null object reference

I also have the latest react native release, 0.61.5 but I haven't got the react-native-splash-screen library added.

This might be an issue with React Native rather than this library not sure

add this to MainActivity:

public void onCreate() {
  SplashScreen.show(this);
}

For those suffering from androidX migration. I've been there and here's how I made it work.
First convert the android.support to its androidx equivalent in SplashActivity.java.
import androidx.appcompat.app.AppCompatActivity;
instead of :
import android.support.v7.app.AppCompatActivity;

and remove the link from the following files:

  • 'MainApplication.java',
  • 'setting.gradle'
  • 'app/build.gradle'.

Hope this will help you as well. Cheers
Btw I'm using "react-native": "^0.62.0-rc.1",

Hi can you explain a little more on what you mean by removing link from mentioned files, and how to do it?

Hi @FaizanMostafa, sorry for the late response, what I meant is removing the code we added when linking the library in android. You can check README file.
You can try automatically run react-native unlink react-native-splash-screen,
or manually remove the lines that were added during manual installation.

one more tip. if you have done all configuration on iOS and you still see the old splash screen, remove the app on the simulator and build again.

Deleting the app surprisingly solved my problem.

@giacomocerquone Really appreciate your help. Wouldn't have realized such a great library is available if I didn't see your answer. Thank you so much again! 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mharrisweb picture mharrisweb  ·  3Comments

Dineshchitta picture Dineshchitta  ·  5Comments

zhaogao picture zhaogao  ·  4Comments

ijry picture ijry  ·  5Comments

luqingxuan picture luqingxuan  ·  3Comments