Go to android/app
run:
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
add these lines to adroid/gradle.properties
, password is keystore password you created when generate keystore
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=123456
MYAPP_RELEASE_KEY_PASSWORD=123456
edit these lines to android/app/build.gradle
...
android {
...
defaultConfig { ... }
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
}
}
}
...
And last command to build release:
rm -rf android/app/build
react-native run-android --variant=release
generate to aab:
cd android
./gradlew bundleRelease
output path:
for apk: /android/app/build/outputs/apk/release
for aab: /android/app/build/outputs/bundle/release
option:
You can create 1build.sh file and allow permission ( on Mac ):
chmod +x ./1build.sh
(on windows, i dont remember the command)