Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load script from assets 'index.android.bundle'.

Tags:

react-native

enter image description here

I get this error after building apk with ./gradlew assembleDebug. If I build apk with ./gradlew assembleRelease, I get an error on install app on mobile phone. When I run same app in virtual device with react-native run-android, app is working fine without any troubles. Any ideas?

  "dependencies": {
    "react": "16.2.0",
    "react-native": "0.52.0",
    "react-navigation": "^1.0.0-beta.27"
  },
  "devDependencies": {
    "babel-jest": "22.1.0",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.1.1",
    "react-test-renderer": "16.2.0",
    "util": "^0.10.3"
  },
like image 376
tourniquet Avatar asked Feb 01 '18 12:02

tourniquet


2 Answers

Step 1: mkdir android/app/src/main/assets

Step 2: In package.json i added:

"scripts": { "bundle": "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" }

Step 3: run "npm run bundle" and in the last order

Step 4: go in android/ folder and

Step 5: run "./gradlew assembleDebug"

Weird bug, and it's still exists until now from 2015!

like image 106
tourniquet Avatar answered Oct 15 '22 23:10

tourniquet


Here are the steps i need you to follow to solve this issue.

Delete android folder and do react-native upgrade (not react-native run-android)

create the folder in the following location.

your_app/android/app/src/main

Perform the following command in root directory. (simply copy and paste the below code)

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 note if you are using index.android.js then replace it in --entry-file.

and lastly

cd android && ./gradlew installDebug

Hope this solves your solution.

like image 34
HungrySoul Avatar answered Oct 16 '22 00:10

HungrySoul