You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot run Android release build when index.android.js not in main directory #11571
Cannot find entry file index.android.js in any of the roots: ["/Users/Documents/reactApp"]
I'm using Typescript to compile assets into an artifacts folder, such that my directory structure is:
reactApp
package.json
ios
android
gradle
...
artifacts
lib
index.android.js
...
...
src
lib
index.android.ts
...
...
Reproduction
Have a directory structure similar to the one above where index.android.js is not in the main directory folder and run: react-native run-android --configuration Release --variant prod
Solution
I believe this was caused by a pull request in 0.39, from @SandroMachado
The react-native bundle command seems to assume the index.android.js exists in the root directory of a project, and no longer sets the process current directory to be the root arg passed in when running react-native run-android.
This is the command executed to generate the release react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output ${androidProjectDir}/app/src/main/assets/index.android.bundle --assets-dest ${androidProjectDir}/app/src/main/res/
So the problem is your index.android.js is under the artifacts directory?
Yup, it is an issue. It is easy to fix, unfortunately that code is not on master anymore. It was removed by 85c8333 So, I cannot make a PR to fix it...
BTW, as a quick fix you can run the release command, directly, I pasted above and fix the directory. It should work.
dang. what would the fix look like? I hardcoded line 115 to look like this:
'--entry-file artifacts/lib/index.android.js ' +
and that results in a new error that makes little sense to me:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processProdReleaseResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/dannycochran/Library/Android/sdk/build-tools/23.0.1/aapt'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I'm guessing this is a separate issue from the one I originally posted, and may have to do with the fact that my app has a webview which loads various assets. When I run:
Five additional directories are created in android/app/src/main/res/:
drawable-hdpi
drawable-mdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
The bundler also creates two files in android/app/src/main/assets/:
index.android.bundle
index.android.bundle.meta
If I remove all these files right after they're created (git clean -f -d) by the bundle command, the app builds successfully on the emulator. If I don't remove them, I get the error above.
Activity
SandroMachado commentedon Dec 20, 2016
Use
--configurationand not--config.2a2d3c6#diff-a003f89d34db18b4567fdb55080a003eR230
dannycochran commentedon Dec 20, 2016
@SandroMachado sorry, my mistake. I am using --configuration.
I was thinking the issue is on line 110 of local-cli/runAndroid/runAndroid.js -- the index.android.js entry file is always expected to be at the root directory, no?
SandroMachado commentedon Dec 20, 2016
This is the command executed to generate the release
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output ${androidProjectDir}/app/src/main/assets/index.android.bundle --assets-dest ${androidProjectDir}/app/src/main/res/So the problem is your
index.android.jsis under theartifactsdirectory?dannycochran commentedon Dec 20, 2016
correct, index.android.js is under artifacts/lib.
when running in dev, I run two separate commands on two different terminal screens:
screen 1:
node node_modules/react-native/local-cli/cli.js start --root artifacts/lib --reset-cachescreen 2:
react-native run-android --variant devIn production, I run:
react-native run-android --configuration Release --variant prod --root artifacts/libBut the artifacts/lib root isn't respected for the line you pasted above, line 110 of local-cli/runAndroid/runAndroid.js
SandroMachado commentedon Dec 20, 2016
Yup, it is an issue. It is easy to fix, unfortunately that code is not on
masteranymore. It was removed by 85c8333 So, I cannot make a PR to fix it...BTW, as a quick fix you can run the release command, directly, I pasted above and fix the directory. It should work.
/cc @grabbou
dannycochran commentedon Dec 21, 2016
dang. what would the fix look like? I hardcoded line 115 to look like this:
'--entry-file artifacts/lib/index.android.js ' +and that results in a new error that makes little sense to me:
SandroMachado commentedon Dec 21, 2016
Hum, can this be a memory (RAM) issue? In the past, developing for Android, I saw that kind of errors caused by insufficient memory.
dannycochran commentedon Dec 21, 2016
I'm guessing this is a separate issue from the one I originally posted, and may have to do with the fact that my app has a webview which loads various assets. When I run:
react-native run-android --configuration Release --variant prodFive additional directories are created in android/app/src/main/res/:
The bundler also creates two files in android/app/src/main/assets/:
If I remove all these files right after they're created (git clean -f -d) by the bundle command, the app builds successfully on the emulator. If I don't remove them, I get the error above.
dannycochran commentedon May 17, 2017
this was fixed by 0.41.0
sahir commentedon May 24, 2017
Thanks @dannycochran it's fixed in 0.41.0. This is the command executed to generate the release Bundle.
react-native bundle --platform android --dev false --entry-file index.android.js \ --bundle-output ../android/app/src/main/assets/index.android.bundle --assets-dest ../android/app/src/main/res/
erm3nda commentedon Jul 5, 2017
Case of my install i have modified the @sahir 's command to:
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/Now the bundle file is present.