DEV Community

Discussion on: Building Serverless or Debug APK for React Native apps

Collapse
 
jonno85 profile image
jonno85 • Edited

packing everything in a script and add the relevant command in package.json
package.json:

...
"scripts": {
"android:offline": "./build_debug_offline.sh",
}
...
Enter fullscreen mode Exit fullscreen mode

create the file in the root folder build_debug_offline.sh, add +x permission to it

build_debug_offline.sh:

#!/bin/bash
set -x

npm start &

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

curl "http://localhost:8081/index.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

cd android && ./gradlew clean assembleDebug

set +x
Enter fullscreen mode Exit fullscreen mode