react-native-bootsplash: error: react-native-bootsplash has not been initialized

Bug report

Summary

I have just finished install react-native-bootsplash and everything works perfectly on ios. but on android I only see the splash screen for a second when opening the app (clicking on the icon). I also get an Error in the console (see below). This error happens when calling RNBootSplash.hide({fade: true});. The .show method also returns the same error. I went over the android install steps multi times, but I can’t seem to see anything i’ve missed.

Error: react-native-bootsplash has not been initialized
promiseMethodWrapper@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:2242:45
hide@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:301970:29

commitHookEffectListMount@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:19628:38
commitPassiveHookEffects@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:19663:44
invokeGuardedCallbackImpl@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:9184:21
invokeGuardedCallback@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:9278:42
flushPassiveEffectsImpl@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:22007:36
unstable_runWithPriority@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:47221:30
scheduleRefresh@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:13057:30
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:44752:38
forEach@[native code]
performReactRefresh@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:44744:31
performReactRefresh@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:44549:48
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:484:40
_callTimer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:30596:17
callTimers@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:30804:19
__callFunction@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:2765:36
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:2497:31
__guard@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:2719:15
callFunctionReturnFlushedQueue@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:2496:21
callFunctionReturnFlushedQueue@[native code]

Environment info

react-native info output:

System:
    OS: macOS 11.2.3
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 2.45 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.0 - /usr/local/opt/node@14/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.11 - /usr/local/opt/node@14/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 26, 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.3
      System Images: android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6953283
    Xcode: 12.3/12C33 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_271 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 3.2.0

Describe what you expected to happen:

splash screen to show until I call ```RNBootSplash.hide({fade: true});`` to hide it.

Thanks in advance

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 18 (8 by maintainers)

Most upvoted comments

@benaficalExchange Found it. You don’t call the correct onCreate method. In Java two methods can have the same name if they have different arguments:

void onCreate (Bundle savedInstanceState) is not the same as void onCreate(Bundle savedInstanceState, PersistableBundle persistentState).

The second is poorly documented (it’s not even in the Activity class documentation) and seems linked to what’s called persistableMode (which requires persistableMode activity attribute)

So, replace this:

@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
  super.onCreate(savedInstanceState, persistentState);

  RNBootSplash.init(R.drawable.bootsplash, MainActivity.this);
  AppCenter.start(getApplication(), "YOUR_API_KEY", Analytics.class, Crashes.class);
}

With this:

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) { // no PersistableBundle persistentState argument!
  super.onCreate(savedInstanceState);

  RNBootSplash.init(R.drawable.bootsplash, MainActivity.this);
  AppCenter.start(getApplication(), "YOUR_API_KEY", Analytics.class, Crashes.class);
}

And it works!

PS: AppCenter was not initialised either! react-native-bootsplash actually helped you caughting this 😄

@zoontek I’ve made a private repo. You should receive an invite. I’ve strip away about 95% of the project and sensitive data. You should be able to build on android and get the error. I’ve also removed the ios files as they are not needed.

Ok, it’s probably your bootsplash.xml which cannot be found. Does it exists?