react-native-bootsplash: Package com.zoontek.rnbootsplash does not exist

Bug summary

Hi, we updated our react-native to version 0.71 recently, and when trying to build the app for Android (Via react-native run-android) after that, the build would fail with:

error: package com.zoontek.rnbootsplash does not exist. import com.zoontek.rnbootsplash.RNBootSplash; the error is thrown in MainActivity.java at the line that is importing the package: import com.zoontek.rnbootsplash.RNBootSplash;

I followed all the steps in the setup section in the readme, and uninstalled and reinstalled the package, ran ./gradlew clean && ./gradlew build but nothing helped. worth noting that I never had issues with this package before. Nothing changed in my env either, only the react-native version.

My code:

-MainActivity.java:

// other imports
import android.os.Bundle;
import com.zoontek.rnbootsplash.RNBootSplash;

public class MainActivity extends ReactActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    RNBootSplash.init(this);
    super.onCreate(null);
    // OR super.onCreate(savedInstanceState); <- did not work either
  }
}

-android/app/src/main/res/values/styles.xml: Is identical to the one in the readme, copy-pasted it

-android/app/build.gradle:


dependencies {
    // other implementations 
    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
    implementation("androidx.core:core-splashscreen:1.0.0")
}

android/app/src/main/AndroidManifest.xml:


  <application
    android:name=".MainApplication"
    android:requestLegacyExternalStorage="true"
    android:label="@string/app_name"
    android:icon="@mipmap/ic_launcher"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:allowBackup="false"
    android:theme="@style/BootTheme"
    android:usesCleartextTraffic="true">
     <!-- … -->
  </application>

Library version

4.6.0

Environment info

System:
    OS: macOS 13.0
    CPU: (8) arm64 Apple M1
    Memory: 121.22 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.15.0 - /usr/local/bin/npm
    Watchman: 2023.04.03.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.12.0 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9014738
    Xcode: 14.0/14A309 - /usr/bin/xcodebuild
  Languages:
    Java: 15.0.2 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: ^0.71.5 => 0.71.6
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  • This issue is only happening on Android.
  • To reproduce:
    • Make sure you are on rn 0.71 project.
    • Install "react-native-bootsplash": "^4.6.0",
    • Try to build the app for Android: react-native run-android

Reproducible sample code

-

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 23 (6 by maintainers)

Most upvoted comments

Hey folks - just sharing my experience with this issue too in the hopes it might help someone in the future!

I upgraded my java version to the Zulu version mentioned in the RN docs to make sure that was setup correctly, but still had the issue. Finally, I was checking what might be going amiss with the RN gradle plugin that does the autolinking in the project and remembered my system default node version is 14 and in the terminal I was using NVM with node at 16 LTS and it always compiled fine there. With that in mind I removed the old, default node version, pointed my PATH to the node 16 version (in my zshrc config), restarted Android Studio and ran gradle sync and it finally picked it up! 🎉

TLDR; Check your node version - the gradle plugin seems to have some weird issues with Node 14, but Node 16 works great (again this is probably why everyone saw different results between terminal and Android Studio not being able to pick up bootsplash)

@Yuniac Good to hear! Yeah, react-native require Java 11 to works correctly. Maybe we should add a quick environment check in the react-native CLI to warn the users if they don’t meet the requirements.

I couldn’t reproduce that. Probably you made a mistake during your update to 0.71 😕

Could you try to provide a reproduction repository with a fresh install to confirm that it’s an actual issue with the library?

Hi, so I went and did that after nothing else has worked.

Fresh RN app which worked, then when I installed the bootsplash package (following the readme steps again), I couldn’t build anymore. Both react-native run-android and ./gradlew build fail again, with the exact same error. I appreciate the time you take to look into this, thanks.

error: package com.zoontek.rnbootsplash does not exist
import com.zoontek.rnbootsplash.RNBootSplash;

MainActivity.java:23: error: cannot find symbol
    RNBootSplash.init(this); // <- initialize the splash screen
    ^
  symbol:   variable RNBootSplash
  location: class MainActivity
2 errors

https://github.com/Yuniac/bootsplash-repro.git

Thank you again

Just want to put my experience with this issue. So I had jdk11 java --version:

openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

and still got this error. This leads me to the conclusion that somehow especially this package is not included in build phase and there for not available for import. After update jdk to the latest one java --version:

openjdk 11.0.19 2023-04-18
OpenJDK Runtime Environment Homebrew (build 11.0.19+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.19+0, mixed mode)

the issue seems gone. PS Not quite sure why exactly this package where ignored for compiling from terminal with older jdk11.

Thank you for replying, it was indeed the Java version messing with it somehow. By removing my old version 15.0.2 and installing 11 (one recommend on RN website: https://reactnative.dev/docs/environment-setup) this problem went away.

Thanks 😃

Just tried with yarn react-native run-android too and no issue on my side. There’s probably something messing with your config, but I cannot guess what.

So problem could be related to auto-linking or something