To customize the APK naming convention for both debug
and release
builds in React Native, follow these steps:
Locate build.gradle
: Navigate to android/app/build.gradle
.
Modify build.gradle
: In the buildTypes
block, add the following code to customize the APK name based on the build type (debug
or release
):
android {
buildTypes {
debug {
signingConfig signingConfigs.debug
// Rename the APK for debug builds
applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "yourappname-${variant.buildType.name}.apk"
}
}
}
release {
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// Rename the APK for release builds
applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "yourappname-${variant.buildType.name}.apk"
}
}
}
}
}
Explanation:
The APK file will be named Fingertip-debug.apk
for the debug build and Fingertip-release.apk
for the release build.
You can adjust the outputFileName
format to include additional details, such as version numbers or other identifiers.
This ensures that each APK has a custom, easily identifiable name based on the build type.