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

Latest script breaks if you have no AndroidManifest.xml under your flavor directories #640

Closed trooperandz closed 3 weeks ago

trooperandz commented 1 month ago

Before submitting a new issue

Bug summary

With the latest 6.* script, new code was added in the generate-bootsplash.ts file, which tries to find and edit the AndroidManifest.xml, along with the colors.xml and styles.xml files (starting on line 557). Pre-version 6, edits to the manifest were a manual step as presented in the README instructions.

For our specific project, we have over 40 flavors, and instead of having a manifest under each /[flavor] directory, we have a single manifest under android/app/src/main, because each flavor shares the same basic Android configuration, except the colors.xml values, which contain the bootsplash background color, and get merged upstream into the main manifest.

The problem is, since we do not have (and don't want) an AndroidManifest.xml file under every /[flavor] directory, the new generate-bootsplash script fails on execution because it requires finding this file there (along with res/values/styles.xml and res/values/colors.xml).

Would it be possible to add a feature flag that bypasses the automatic AndroidManifest.xml, styles.xml, and colors.xml file edits in the script?

The thought is that the latest library assumes/forces your /android directory structure to have a specific structure setup in the case of multiple flavors; in our case, adding these files is not necessary and would fail to adhere to the DRY principle.

Perhaps a flag such as --skip-manifest or something might suffice?

Library version

6.5.1

Environment info

System:
  OS: macOS 14.5
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 25.88 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.9.0
    path: ~/.nvm/versions/node/v22.9.0/bin/node
  Yarn:
    version: 4.5.0
    path: ~/.nvm/versions/node/v22.9.0/bin/yarn
  npm:
    version: 10.8.3
    path: ~/.nvm/versions/node/v22.9.0/bin/npm
  Watchman:
    version: 2023.02.20.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/matthewholland/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    API Levels:
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "34"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 29.0.3
      - 30.0.0
      - 30.0.1
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 32.1.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
    System Images:
      - android-29 | Intel x86 Atom_64
      - android-30 | Google APIs Intel x86 Atom
      - android-31 | Google Play Intel x86 Atom_64
      - android-R | Google Play Intel x86 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 1.8.0_265
    path: /usr/bin/javac
  Ruby:
    version: 3.1.3
    path: /Users/matthewholland/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.4
    wanted: 0.75.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to reproduce

  1. Open a React Native project which has multiple android flavors.
  2. Place only one AndroidManifest.xml file in the android/app/src/main/ directory (leave none under your flavor directory).
  3. Run the react-native generate-bootsplash script per usual, including the --flavor flag.
  4. Notice that the script fails during execution since it cannot find the android/app/src/[flavor] manifest file.

Reproducible sample code

`yarn react-native generate-bootsplash src/config/clients/[flavor]/assets/app-logo-splashscreen.png --background="#000000" --logo-width="250" --flavor [flavor]`
zoontek commented 3 weeks ago

Fixed in 6.5.0