Skip to content

Missing JS bundles when using android flavors in release builds #32338

Description

@MichaelBorde

Description

Some JS bundles (index.android.bundle) are missing in apks when using android flavors.

There has been this attempt to fix the bug: #32026

I can confirm the bug is still present in React Native 0.66.0.

React Native version:

System:
    OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 3.84 GB / 15.26 GB
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 12.22.6 - ~/.nvm/versions/node/v12.22.6/bin/node
    Yarn: Not Found
    npm: 6.14.15 - ~/.nvm/versions/node/v12.22.6/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    Android SDK:
      API Levels: 16, 23, 26, 27, 28, 29, 30
      Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 27.0.3, 28.0.2, 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3
      System Images: android-26 | Google Play Intel x86 Atom, android-29 | Intel x86 Atom_64
      Android NDK: 20.1.5948944
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 1.8.0_252 - /home/michael/.sdkman/candidates/java/current/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.0 => 0.66.0 
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

I have made this repository: https://github.com/MichaelBorde/RN066FlavorBundleIssue.

It is based on standard template (npx react-native init) with minimal modifications in android/app/build.gradle to define flavors.

Just create some release apks:

cd android
./gradlew clean assembleRelease

Inspect both crated apks you will find one with JS bundle and one missing it.

find . -name "*.apk" -exec unzip -l {} \; | grep assets

(Only 1 line will be present)

Expected Results

I expect to get a JS bundle in each created apk.

A potential fix

The following code could fix the issue: https://github.com/MichaelBorde/RN066FlavorBundleIssue/blob/main/android/app/build.gradle#L206.

Such a fix might be fragile because it is based on task name (a string) and such a name or task ordering might be changed in com.android.tools.build:gradle.

Similar issues

This issue is similar: #31157.

But this current issue does not concern proguard at all and targets React Native 0.66.0 which should include a fix (non working in my case).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions