How to Generate a React Native Release Build APK for Android
in this video tutorial i will explain how you can create release apk for android.
Generating an upload key
First Step go to the project root directory.
in this video tutorial i will explain how you can create release apk for android.
Generating an upload key
You can generate a private signing key using
keytool
. On Windows keytool
must be run from C:\Program Files\Java\jdkx.x.x_x\bin
.First Step go to the project root directory.
Write the cmd and open the command prompt
Generating an upload key
The
keystore contains a single key, valid for 10000 days. The alias is a name that
you will use later when signing your app, so remember to take note of the
alias.
Note: Remember to keep your
keystore file private and never commit it to version control.
press enter then it will start process to generate.
my-release-key.keystore file need to put the android/app folder.
gradle.properties setup
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=enter your password here
MYAPP_RELEASE_KEY_PASSWORD= enter your password here
android/app/build.gradle
defaultConfig Section add this codding
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
}
}
}
Built type need to add those line
signingConfig signingConfigs.release
Now you need to process some command in cmd go to the cd android folder
Now enter the command .\gradlew clean. its means it will clean the previous apk. and it will generate again. if your apk is stopped working you need to generate this .\ gradlew assembleRelease –stacktrace
if you found more error ./gradlew --warning-mode=all
if gradlew is giving any error run the command ./gradlew --stop
Run this command to generate sign in apk gradlew
assembleRelease
after generating the apk. you will find apk here
android\app\build\outputs\apk\release
if you find any problem with generating apk you can knock me into the command section below.
Have a good day!