Hopefully it will help new beginners
Official doc here
If you dont have keystore than use before command else skip
Generating a signing key / Keystore file
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.
$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
you will get a file like my-release-key.keystore
Setting up gradle variables
Place the my-release-key.keystore file under the android/app directory in your project folder.
Edit the file android/gradle.properties and add the following (replace ***** with the correct keystore password, alias and key password),
enableAapt2 set false is workaround , as android gradle version 3.0 problem
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****
android.enableAapt2=false
then add these app/buid.gradle (app)
below default config
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
}
}
and Inside Build type release { }
signingConfig signingConfigs.release
then simply run this command in android studio terminal
Below commands will automate above all answers
if windows
cd android
gradlew assembleRelease
if linux / mac
$ cd android
$ ./gradlew assembleRelease
if you got any error delete all build folder and run command
gradlew clean
than again
gradlew assembleRelease