How to Generate APK in React Native: Step-by-Step Guide
To generate an APK in React Native, first create a release build using
./gradlew assembleRelease inside the Android folder. Then find the APK file in android/app/build/outputs/apk/release/app-release.apk to install or distribute.Syntax
Generating an APK involves running Gradle commands inside the Android project folder of your React Native app.
cd android: Move to the Android folder../gradlew assembleRelease: Build the release APK.- APK output path:
app/build/outputs/apk/release/app-release.apk.
bash
cd android ./gradlew assembleRelease
Output
BUILD SUCCESSFUL in 30s
...
Example
This example shows how to generate a release APK for a React Native app on a Unix-like system.
bash
cd android ./gradlew assembleRelease # After build completes, find APK at: # app/build/outputs/apk/release/app-release.apk
Output
BUILD SUCCESSFUL in 30s
...
Common Pitfalls
Common mistakes include:
- Not setting up signing configs in
android/app/build.gradle, which is required for release APKs. - Running commands outside the
androidfolder. - Using debug build commands instead of release.
- Not cleaning the build folder before rebuilding, causing stale builds.
bash
Wrong: cd .. ./gradlew assembleRelease Right: cd android ./gradlew clean ./gradlew assembleRelease
Quick Reference
Summary tips for generating APK:
- Always run commands inside the
androidfolder. - Configure signing keys in
android/app/build.gradlefor release builds. - Use
./gradlew cleanbefore building to avoid errors. - Find your APK at
android/app/build/outputs/apk/release/app-release.apk.
Key Takeaways
Run
./gradlew assembleRelease inside the android folder to build the APK.Configure signing in
android/app/build.gradle for release APKs.Always clean the build with
./gradlew clean before building to avoid stale errors.The generated APK is located at
android/app/build/outputs/apk/release/app-release.apk.Run commands inside the android folder, not the project root.