How to build a Debug APK for React Native apps

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.


What is an Apk?


  • Android package kit (Apk) is the package file format used by the Android operating system for distribution and installation of mobile apps and middle ware.
  • Apk files are compressed all format files.
  • Apk file extension file_name.apk


What is Debug Apk:


  • An Android app will execute in debug mode in the development environment
  • The debug apk must be enabled the debug logging, StrictMode and the debugging options.
  • The debug apk not ready for the app stores.


Creating the debug Apk?


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