6

enter image description hereI want to build unsigned apk or debug apk. My application is successfully running on localhost. I have tried different methods. But it shows the error. I have got the answer from Here . when applying the command

 react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug

It showing the error is

Cannot find entry file index.android.js in any of the roots: ["D:\\workspace\\reactjs\\native\\myapp5"]

Then i have change index.android.js to App.js

Then it will showing the error is

ENOENT: no such file or directory, open 'D:\workspace\reactjs\native\myapp5\android\app\build\intermediates\assets\debug\index.android.bundle'

How to solve this problem? Please help me.

My react native versions are react-native-cli: 2.0.1 , react-native: 0.52.0 . Screenshot of my root folder i have posted.

when i run gradlew assembleDebug in android folder it showing the error.

enter image description here

6
  • please confirm index.android.js exist in your root, it might be index.js not index.android.js in newer version of react-native, Commented Mar 23, 2018 at 4:37
  • index.js is not found in root folder. App.js is available in root folder. Commented Mar 23, 2018 at 4:40
  • can you share screenshot of your root directory Commented Mar 23, 2018 at 4:44
  • i have posted the screenshot. pls chck it. Commented Mar 23, 2018 at 5:45
  • where is your entry file index.android.js ? Commented Mar 23, 2018 at 6:14

4 Answers 4

22

In your root project directory

Ensure you already have a directory android/app/src/main/assets/. If not already there, create a directory.

After that create a new file and save it as index.android.bundle and put your file in like this android/app/src/main/assets/index.android.bundle

After that has been done, run the following command

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

and finally, run the following command.

cd android && ./gradlew assembleDebug

then you can get apk app/build/outputs/apk/debug/app-debug.apk

Sign up to request clarification or add additional context in comments.

2 Comments

This is the correct solution latest react native SDK. Worked well on 0.55.9
Worked as of March 2023.
4

The problem here is that you do not seem to have the entry file you have specified for react native bundle:

index.android.js

Replace it with your project's entry file index.js or app.js according to your project structure.

Update:

react-native bundle --dev false --platform android --entry-file <your-entry-file> --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug

Create debug build:

cd android && ./gradlew assembleDebug

Your apk will be at android/app/build/outputs/apk

12 Comments

I have used app.js. Then it shows the error is " ENOENT: no such file or directory, open 'D:\workspace\reactjs\native\myapp5\android\app\build\intermediates\assets\debug\index.android.bundle' "
@Joe I updated my answer. replace your entry file name with <your-entry-file>
showing the same error. " ENOENT: no such file or directory, open 'D:\workspace\reactjs\native\myapp5\android\app\build\intermediates\assets\debug\index.android.bundle"
@Joe can you post the output of cd android && ./gradlew assembleDebug
The output is " The system cannot find the path specified. "
|
2

In the root folder of your project, run the following command:

For RN Old Version:

mkdir -p android/app/src/main/assets && rm -rf android/app/build && 
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 
&& cd android && ./gradlew clean assembleDebug && cd ../

For RN New Version:

mkdir -p android/app/src/main/assets && rm -rf android/app/build && 
react-native bundle --platform android --dev false --entry-file index.js 
--bundle-output android/app/src/main/assets/index.android.bundle 
--assets-dest android/app/src/main/res && 
cd android && ./gradlew clean assembleDebug && cd ../

The apk is generated in following folder:

app/build/outputs/apk/debug/app-debug.apk

And if you want to run the apk on simulator. Run the following command:

react-native run-android --variant=debug

Comments

2

This will work..

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

cd android && ./gradlew assembleDebug

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.