zoontek / react-native-bootsplash

🚀 Show a splash screen during app startup. Hide it when you are ready.
MIT License
3.73k stars 257 forks source link

Expo Bare Workflow - Android Splash is hiding immediatley #606

Closed ph8nt0m closed 3 months ago

ph8nt0m commented 3 months ago

Before submitting a new issue

Bug summary

In android, SplashScreen is hiding immediately and it blink when I call hide()

Library version

^6.1.1

Environment info

System:
  OS: macOS 14.2.1
  CPU: (12) arm64 Apple M2 Max
  Memory: 466.41 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.0
    path: /opt/homebrew/opt/node@16/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 8.19.4
    path: /opt/homebrew/opt/node@16/bin/npm
  Watchman:
    version: 2024.07.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.3
    wanted: 0.74.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to reproduce

https://github.com/user-attachments/assets/975db537-c113-481d-9329-07a5f856dd83

init().finally(async () => {
      await new Promise((resolve) => setTimeout(resolve, 3000));
      await BootSplash.hide({ fade: true });
    });
<resources>
    <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="android:windowLightStatusBar">true</item>
    </style>

    <style name="BootTheme" parent="Theme.BootSplash.EdgeToEdge">
        <item name="darkContentBarsStyle">true</item>

        <item name="bootSplashBackground">@color/bootsplash_background</item>
        <item name="bootSplashLogo">@drawable/bootsplash_logo</item>
        <item name="postBootSplashTheme">@style/AppTheme</item>
    </style>
</resources>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resources>
  <color name="bootsplash_background">#ffffff</color>
</resources>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
  <uses-permission android:name="android.permission.VIBRATE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <queries>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:scheme="https" />
    </intent>
  </queries>
  <application
    android:name=".MainApplication"
    android:label="@string/app_name"
    android:icon="@mipmap/ic_launcher"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:allowBackup="false"
    android:theme="@style/AppTheme">
    <activity
      android:name=".MainActivity"
      android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode"
      android:launchMode="singleTask"
      android:windowSoftInputMode="adjustResize"
      android:theme="@style/BootTheme"
      android:exported="true">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="frism-app" />
      </intent-filter>
    </activity>
    <activity
      android:name="com.facebook.react.devsupport.DevSettingsActivity"
      android:exported="false" />
  </application>
</manifest>
override fun onCreate(savedInstanceState: Bundle?) {
    RNBootSplash.init(this, R.style.BootTheme)
    super.onCreate(null)
  }

Reproducible sample code

I attach my code
zoontek commented 3 months ago

@ph8nt0m Are you using expo-dev-launcher? There's an issue in it.

ph8nt0m commented 3 months ago

I got it

override fun onCreate(savedInstanceState: Bundle?) {
    DevLauncherSplashScreenProvider()
      .attachSplashScreenViewAsync(plainActivity)
    redirect(plainActivity.intent)
  }

=>

override fun onCreate(savedInstanceState: Bundle?) {
    redirect(plainActivity.intent)
  }

I change it but it occurs again

zoontek commented 3 months ago

@ph8nt0m You have to patch the package + clear the build cache. You could also uninstall it.

ph8nt0m commented 3 months ago

npx patch-package expo-dev-launcher

rm -rf node_modules && yarn

./gradlew clean

yarn android

I did all but it occurs again

package expo.modules.devlauncher.react.activitydelegates

import android.content.Intent
import android.os.Bundle
import com.facebook.react.ReactActivity

class DevLauncherReactActivityRedirectDelegate(
  activity: ReactActivity,
  private val redirect: (Intent?) -> Unit
) : DevLauncherReactActivityNOPDelegate(activity) {

  override fun onCreate(savedInstanceState: Bundle?) {
    redirect(plainActivity.intent)
  }
}
ph8nt0m commented 3 months ago

I delete expo-dev-client and solved it

Thanks a lot