question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error: react-native-bootsplash has not been initialized

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
zoontekcommented, Apr 23, 2021

@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 😄

1reaction
thomas-forster1commented, Apr 22, 2021

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS 15 throws "react-native-bootsplash has not been initialized"
I tried running 3 projects with the same version of bootsplash (3.2.5) on iOS 14.5 Simulator. Only 1 project has bug. Somehow, bootsplash...
Read more >
How to get started with react-native-bootsplash - Stack Overflow
Step 1: Add the package to react-native project ... RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); // <- display the generated ...
Read more >
react-native-bootsplash - Bountysource
Occasionally (but rarely) I get this error due to react-native-bootsplash , causing the app to hang: ... react-native-bootsplash has not been initialized
Read more >
react-native-bootsplash/README.md - UNPKG
As Android will not create our main activity before launching the app, we need to display a different activity at start, then switch...
Read more >
react-native-bootsplash - npm
react -native-bootsplash. Show a splash screen during app startup. Hide it when you are ready. For migration from the v3, check the MIGRATION....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found