react.gradle doesn't create index.android.bundle - Android
I created a sample project using 'react-native init project' on Mac OS.
When I run ./gradlew assembleRelease no index.android.bundle file gets created. Plus no react related tasks appear in Android Studio.
It seems like the command:
commandLine "node", "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir doesn't run.
When I run the same command manually everything works smoothly.
Not sure how relevant this is but the command :```
doFirst {
jsBundleDir.mkdirs()
resourcesDir.mkdirs()
}
Also doesn't work, unless I take both commands outside the "doFirst".
Any suggestions ?
@facebook-github-bot label Android
So i'm pretty sure it's gradle related. When I put the same code inside a script it works.
So now I call it like this:
commandLine './packageJS.sh',"--devEnabled","${devEnabled}", "--entryFile", entryFile, "--jsBundleFile", jsBundleFile, "--resourcesDir", resourcesDir
And my packageJS.sh :
while [[ "$#" > 1 ]]; do case $1 in
--entryFile) entryFile="$2";;
--devEnabled) devEnabled="$2";;
--jsBundleFile) jsBundleFile="$2";;
--resourcesDir) resourcesDir="$2";;
*);;
esac; shift
done
node node_modules/react-native/local-cli/cli.js bundle --platform android --dev ${devEnabled} --entry-file ${entryFile} --bundle-output ${jsBundleFile} --assets-dest ${resourcesDir}
exit 0
The last thing is that for some reason the task bundleReleaseJsAndAssets doesn't seem to run, so what I ended up doing is :
// Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process
currentBundleTask.dependsOn("merge${targetName}Resources")
currentBundleTask.dependsOn("merge${targetName}Assets")
runBefore("processArmeabi-v7a${targetName}Resources", currentBundleTask)
runBefore("processX86${targetName}Resources", currentBundleTask)
runBefore("processUniversal${targetName}Resources", currentBundleTask)
runBefore("process${targetName}Resources", currentBundleTask)
currentBundleTask.execute()
And to generate the **index.android.bundle** file:
`./gradlew assembleRelease`
P.S - Worth mentioning that this still doesn't work when I build the project for release inside Android Studio. For that to work I had to create a symbolic link :
ln -s /Users/**<your_user>**/.nvm/versions/node/v5.10.1/bin/node /usr/local/node
And inside react.gradle I add the following:
def PATH = environment.getAt("PATH")
PATH = PATH + ":/usr/local"
environment.putAt("PATH",PATH)
When you run ./gradlew assembleRelease it does indeed create the bundle, but it creates it in the app/build/intermediates/assets/release directory, so you wouldn't see that in your source control or even know that it exists normally.
@facebook-github-bot expected
The comment above tells me this is expected behavior. Closing this as we'd like to use the GitHub issue tracker for bugs. If you'd like to change how this feature works please post a feature request on Product Pains so that other people can vote on it.
@dsibiski I obviously know it should have been created it in the app/build/intermediates/assets/release folder, that's exactly the problem, that for me it doesn't.
It looks like you're not experiencing the issue I am.
@idan-ratzabi Thanks for clarifying. Just to be sure, you definitely have a valid keystore there setup in your build.gradle?
Also if it's at all possible to put together a sample repo ready to run this command (with a keystore and everything) it would greatly help us to be able to more easily debug on our end. 😄
Actually it happens even on an empty project created with react-native init.
I'm attaching the one i just created again to make sure. I also created a key store with it.
running ./gradlew assembleRelease doesn't produce any index.android.bundle file.
I suspect it might be an issue with my environment, though I'm not 100% sure.
@idan-ratzabi Yeah it looks like it's a problem with your env as the bundle builds fine for me:

@dsibiski so weird. Have no idea what could it be. Can you tell me your environment details ? OS, Gradle version, shell etc'.... Thanks
OS X 10.10.5 Gradle Version: 2.10 (it seems like it gets installed with each app, not globally) Shell: zsh
This is what I have installed for Android:

Looks like we have more or less the same environment :/
@dsibiski Apparently the issue was org.gradle.configureondemand=true set in my gradle.properties.
Had to remove it and stuff went back to normal on my local machine.
Unfortunately now I have the same issue on Travis, though there the gradle properties seem to be fine. Maybe you can help with that ? Opened another issue : https://github.com/facebook/react-native/issues/7325
I face the same problem , and I did not add org.gradle.configureondemand=true in my gradle.properties, assembleRelease does not run bundleReleaseJsAndAssets task.
@AvatarQing did you check in your ~./gradle folder as well ? Do you use flavor dimensions by any chance ?
@idan-ratzabi Hi, thanks for reply, I think I found the reason. My OS is windows7, I created an empty project with react-native init, and configed a keystore for release build type, now if I run gradle assembleRelease in command line,bundleReleaseJsAndAssets is executed, but when I run app in Android Studio (I choose the build variant to release), bundleReleaseJsAndAssets doesn't executed. I just thought the two ways have the same functionality, but now it appears there is something different between them. I can't figure out the difference for now.
The only difference I can think of are environment variables might not be present while running from Android Studio, so perhaps it can't find some modules (node, for instance) ? But you say no error appears, so i'm not sure either..
You said exactly right. In Android Studio, go to File | Settings | Build, Execution, Deployment | Compiler, the option Configure on demand is checked by default for speeding up builds, uncheck it then everything is ok now.
Great you found it!
Great! Cool!!
not add org.gradle.configureondemand=true in gradle.properties
but, why?
Thank you @AvatarQing @idan-ratzabi ...and everybody !