DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Hammad Hassan
Hammad Hassan

Posted on • Updated on

Generate Release APK (app-release.apk) in React Native for Android

Here I'm writing some very simple and easy steps to generate release APK for android that is also used to upload and publish to play store.

Step One

First of all you have to generate your store key file. So, go to your
C:\Program Files\Java\jdk1.8.0_251\bin
folder and open command prompt (Open as an administrator that is a best practice) and paste this below line

keytool -genkey -v -keystore your_key_name.keystore -alias your_key_alias -keyalg RSA -keysize 2048 -validity 10000

Now you will be asked some simple queries like password, your organizational name etc. Give them an answer. After completing this process you will see your generated store key file at your

C:\Program Files\Java\jdk1.8.0_251\bin
folder.

Step Two

Now come to your android/gradle.properties and setup your gradle variables

MYAPP_RELEASE_STORE_FILE=your_keystor_ename.keystore
MYAPP_RELEASE_KEY_ALIAS=your_keyalias
MYAPP_RELEASE_STORE_PASSWORD=your_pass
MYAPP_RELEASE_KEY_PASSWORD=your_pass

Step Three

Now you have to come in your andoid/app/build.gradle and setup your signingconfig

android {
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
}
}
}

Now you are all done. Go to your android folder and generate release apk by this command

gradlew assembleRelease

Let me know if you get any sort of error! I will be glad to helping you out! Thanks

Top comments (2)

Collapse
 
hamedvb61 profile image
hamed abdollahi

hi, I did these steps but when I wanna run release.apk on my phone it doesn't install !!

Collapse
 
hmadhsan profile image
Hammad Hassan • Edited on

Hi, Can u pls tell me what error did u encounter in your cmd?

Image description

Join the One Year Club

You can earn this badge by being a registered member of the DEV Community for at least one year. Create an account and get started today.