React Native Publishing an Android App

Add/Create Keystore
This command will create a keystore with the given name if the file doesn't exist or append a key to a current keystore.
keytool -genkey -v -keystore mykeystore.keystore -alias mykeyalias -keyalg RSA -keysize 2048 -validity 10000
After you have generated the mykeystore.keystore file copy it to android/app
.
Setting up gradle variables
Append the snippet below to android/gradle.properties
and add the correct values.
MYAPP_RELEASE_STORE_FILE=mykeystore.keystore
MYAPP_RELEASE_KEY_ALIAS=mykeyalias
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****
Adding signing config to your app's gradle config
Edit android/app/build.gradle
so it looks similar to the one below.
...
android {
...
defaultConfig { ... }
signingConfigs {
release {
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
}
}
}
...
Add the siginingConfigs
snippet right below but not in defaultConfig
and then append signingConfig signingConfigs.release
to buildTypes -> release
.
Generating the release APK
cd android && ./gradlew assembleRelease
Testing the release build of your app
cd android && ./gradlew installRelease
Where is my bundled app?
The file you want to upload to the Google Play Store is android/app/build/outputs/apk/app-release.apk
Update version number for each build
In android/app/build.gradle
increment:
versionCode 2
versionName "2.0"
Helpful Commands
# List aliases within a keystore with this command:
keytool -list -keystore mykeystore.keystore