Skip to content

Android react.gradle bundle settings ignored #12135

Closed
@chuckhacker

Description

@chuckhacker

Description

When renaming the bundle and specifying bundleIn{Debug,Release} in build.gradle like so:

project.ext.react = [
        // the name of the generated asset file containing your JS bundle
        bundleAssetName: "index.bundle",

        // the entry file for bundle generation
        entryFile: "index.js",

        // whether to bundle JS and assets in debug mode
        bundleInDebug: true,

        // whether to bundle JS and assets in release mode
        bundleInRelease: true,
]

apply from: "../../node_modules/react-native/react.gradle"

These settings are ignored and the following error is always displayed, suggesting that RN is still looking for the old index.android.js and not the new index.js:
http://imgur.com/a/oqTMf

The problem persists even after restarting react-native start.

As you can see, it is still looking for index.android.js AND it is still not bundling the JS in debug mode.

Reproduction

Easy to reproduce, just use react-native init and try to rename the bundle. For example (remove the "android") in build.gradle (Module: app) as follows:

project.ext.react = [
        // the name of the generated asset file containing your JS bundle
        bundleAssetName: "index.bundle",

        // the entry file for bundle generation
        entryFile: "index.js",

        // whether to bundle JS and assets in debug mode
        bundleInDebug: true,

        // whether to bundle JS and assets in release mode
        bundleInRelease: true,
]

apply from: "../../node_modules/react-native/react.gradle"

Then, run either using react-native run-android or by opening the Android Studio project and pressing the play button.

Solution

React Native needs to abide by the project.ext.react gradle settings and look in the correct place for the bundle (and use the bundle in debug mode as well when specified).

Additional Information

  • React Native version: 0.40.0
  • Platform: Android
  • Operating System: macOS 10.12.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions