How to Generate a React Native Build APK Using Version 0.71.2
To generate a React Native build APK for version 0.71.2, configure your Android project for SDK 33, create a release signing keystore, and run ./gradlew assembleRelease from the android directory to output a signed APK at android/app/build/outputs/apk/release/app-release.apk.
React Native 0.71.2 requires specific toolchain versions and Android SDK configurations to produce production-ready APKs. This guide walks through the complete build process using the source conventions from the facebook/react repository, ensuring compatibility with the React 19.3.0 core version specified in ReactVersions.js.
Prerequisites for React Native 0.71.2
Before generating a release build, verify your environment matches the requirements for React Native 0.71.2:
- Node.js: Version 18 LTS or later
- Java Development Kit: OpenJDK 11 (check with
java -version) - Android Studio: Arctic Fox 2020.3.1 or later with Android SDK Platform 33 (Android 13)
- Gradle: 7.5 or later (handled automatically by the Gradle Wrapper at
./gradlew)
Install dependencies and clean the Android build cache:
yarn install
cd android && ./gradlew clean
Configure Android Project Settings
React Native 0.71.2 targets Android SDK 33 by default. Verify these values in your project configuration files.
In android/build.gradle, ensure the global SDK versions are set:
buildscript {
ext {
compileSdkVersion = 33
buildToolsVersion = "33.0.0"
}
}
In android/app/build.gradle, confirm the minimum and target SDK versions:
android {
defaultConfig {
minSdkVersion = 21
targetSdkVersion = 33
}
}
Additionally, ensure android/gradle.properties contains AndroidX migration flags required by React Native 0.71.2:
android.useAndroidX=true
android.enableJetifier=true
Set Up Release Signing Configuration
Generate a production keystore if you haven't already. From the project root, run:
keytool -genkeypair -v -keystore android/app/my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
Add signing credentials to android/gradle.properties (keep this file secure and out of version control):
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=your_store_password
MYAPP_RELEASE_KEY_PASSWORD=your_key_password
Reference these properties in android/app/build.gradle within the signingConfigs block:
android {
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Build the Release APK
With signing configured, generate the release APK using Gradle. From the android directory:
./gradlew assembleRelease
The build process compiles JavaScript bundles and native code, outputting the signed APK to:
android/app/build/outputs/apk/release/app-release.apk
For Google Play Store distribution, generate an Android App Bundle (AAB) instead:
./gradlew bundleRelease
This creates android/app/build/outputs/bundle/release/app-release.aab, which is the preferred format for Play Store uploads.
Verify Version Compatibility and Common Issues
React Native 0.71.2 depends on React 19.3.0 as defined in ReactVersions.js within the facebook/react repository. Ensure your app's package.json pins these exact versions to avoid native module mismatches:
{
"dependencies": {
"react": "19.3.0",
"react-native": "0.71.2"
}
}
If you encounter Invariant Violation: "NativeModule" is not a registered callable module, the React core version likely mismatches the React Native native code. Run yarn install and clean the Gradle build to resolve cache conflicts.
For Gradle build failures citing "Failed to resolve: com.facebook.react:react-android", verify that android/build.gradle includes both mavenCentral() and google() in the repositories block.
Summary
- React Native 0.71.2 requires Android SDK 33, OpenJDK 11, and Node 18 LTS for optimal build performance.
- Configure signing credentials in
android/gradle.propertiesand reference them inandroid/app/build.gradleto enable release builds. - Execute
./gradlew assembleReleaseto generate a signed APK or./gradlew bundleReleasefor Play Store AAB distribution. - Match the React core version (19.3.0) specified in
ReactVersions.jsto prevent runtime native module errors. - Clean the Gradle cache with
./gradlew cleanbefore building after version upgrades to prevent resource duplication errors.
Frequently Asked Questions
What is the difference between assembleRelease and bundleRelease?
assembleRelease generates a standard APK file suitable for direct installation via adb install or manual distribution, while bundleRelease creates an Android App Bundle (AAB) that Google Play uses to generate optimized APKs for different device configurations. For Play Store submissions, use bundleRelease; for internal testing or sideloading, use assembleRelease.
Where does React Native 0.71.2 specify its Android SDK requirements?
The default SDK versions for React Native 0.71.2 are defined in the template files android/build.gradle and android/app/build.gradle, setting compileSdkVersion and targetSdkVersion to 33. These values ensure compatibility with the native modules shipped in the react-android artifact.
How do I fix "Failed to resolve: com.facebook.react:react-android" errors?
This error indicates missing Maven repositories in your android/build.gradle file. Add mavenCentral() and google() to the allprojects.repositories block, then sync the project. This allows Gradle to download the React Native 0.71.2 Android dependencies from the correct repositories.
Can I use a debug build instead of release for testing?
Yes, run npx react-native run-android to generate and install a debug APK with the Metro bundler attached. However, debug builds include development menus, unminified JavaScript, and debug symbols, resulting in significantly larger file sizes and slower performance compared to release builds generated via ./gradlew assembleRelease.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →