Tuesday, September 13, 2016

React Native: Change the Entry file path index.android.js to specified custom file path

Leave a Comment

I need to change the Entry file path to src/XXXApp.android.js instead of pointing to default index.android.js file. I want to keep the JS file in seperate ./src folder.

So that I made the change in ./android/app/build.gradle like

 project.ext.react = [     bundleAssetName: "src/XXXApp.android.bundle",     entryFile: file("../../src/XXXApp.android.js"),     root: "../../../../",     inputExcludes: ["android/**", "./**"]  ] 

and in .\node_modules\react-native\react.gradle file like

def bundleAssetName = config.bundleAssetName ?:"src/XXXApp.android.bundle" def entryFile = config.entryFile ?: "src/XXXApp.android.js" 

But development package server always pointing to localhost:8081/index.android/bundle. . Manually i tried the URL: localhost:8081/src/XXXApp.android.bundle and it retrieve the data. But in device debug loadJs always try the localhost:8081/index.android/bundle.

Please share the solution, proper place to update the entry file config for android. Appreciate in advance for your valuable solution.

1 Answers

Answers 1

In your MainActivity you can override getJSBundleFile() method of ReactActivity. Here you can specify your bundle file name along with the path. Code push use same method of override reactjs bundle path.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment