36

When I run

npx react-native run-android --variant=release 

in RN 0.61.3 and I receive this error message.

ENOENT: no such file or directory, open 'android/app/src/main/assets/index.android.bundle'

The build works fine when debugging without the release variant.

Matt Booth
  • 1,723
  • 3
  • 13
  • 19

8 Answers8

113

For some reason I needed to create the assets folder as per below.

android/app/src/main/assets

GabLeRoux
  • 16,715
  • 16
  • 63
  • 81
Matt Booth
  • 1,723
  • 3
  • 13
  • 19
  • I created project React Native, I couldn't find the assets folder. I had to create and this worked. – Diego Santa Cruz Mendezú Apr 09 '22 at 20:33
  • Failed to open file H:\My Projects\Rannlab2\BharatDarshan020App\android\app\build\generated\assets\react\release\index.android.bundle.hbc.ee6df4: no such file or directory . This is my error and your solution is not working for me. Do you have any solution for my problem? if you have please share – Rohullah Nabavi Jul 25 '22 at 07:06
11

I had the assets folder already, but mistakenly had kept on being in the android folder, I went in parent directory with

cd ..

then ran the following command to generate the bundle:

npx 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
GabLeRoux
  • 16,715
  • 16
  • 63
  • 81
microsoftjulius
  • 300
  • 3
  • 10
7
  • Go to android/app/src/main/
  • Create one more folder of the name assets
    It will look like android/app/src/main/assets
  • Then run it. Absolutely workable.
greybeard
  • 2,249
  • 8
  • 30
  • 66
sherkhan
  • 811
  • 8
  • 8
5

Right click the app folder New->Folder->Assests Folder

enter image description here

RodneyO
  • 125
  • 1
  • 7
2

You can use this command:

npx mkdirp android/app/src/main/assets/ && 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/
Elikill58
  • 4,050
  • 24
  • 23
  • 45
ViShU
  • 300
  • 2
  • 10
1

We can use this command:npx mkdirp android/app/src/main/assets/ && 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/

0

You should use this command to create assets folder in android.

Run this command in project directory.

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

Please use this, Its help me.

Mayank Garg
  • 1,284
  • 1
  • 11
  • 23
0

First of all make dir or folder named as assets inside project/android/app/src/main/ manually or by running command below from root of project

npx mkdirp android/app/src/main/assets/ 

then run this command from root of project:

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/

Create debug apk:

cd android/
./gradlew assembleDebug

and You will get apk here:

android/app/build/outputs/apk/
راجہ مخلص
  • 1,177
  • 6
  • 15