How to build a Debug APK for React Native apps
Last Updated On October 27, 2021
Last Updated On October 27, 2021
If you are a react native developer, I am pretty sure that you have faced the problem of creating a signed APK to test it on another device?. So here is the steps that you can follow to create a debug APK easily. Before that let’s see get some idea about apks.
Basically, the process is very easy. Open a terminal/command prompt inside the root directory of your project and run the following commands:
1. Start the node packaging bundler:
npm start
2. When the terminal shows: “Loading dependency graphs….”, open a new terminal in the same directory and now run the following to create a new directory inside the app to store the assets:
mkdir -p android/app/src/main/assets
3. Use react-native’s bundle to bundle the assets in the directory created above:
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
4. Curl the .js files created to the index.android.bundle: copy below command and paste it on terminal and run it.
curl "http://localhost:8081/index.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
5. Change to /android directory and run gradlew to build the APK:
cd android && ./gradlew clean assembleDebug
Well, that’s it. Easy, peasy! After everything is done and it shows “Build successful”, your APK will be present in the folder
<project>/android/app/build/outputs/apk/debug