After the development process, if we want to distribute our application, or upload it on Google Play Store then we need a signed APK and to generate signed APK we have to generate our signed Keystore which stores name, company name, password, etc.
A file with the APK extension is an Android Package file that's used to distribute applications on Google's Android OS
APK files are saved in the ZIP format and are typically downloaded directly to Android devices, usually via the Google Play store, but can also be found on other websites.
the below steps can be used to generate an APK for our aplication
Run Terminal/Command prompt as administrator, navigate to your project folder and run the below command
keytool -genkey -v -keystore your-release-key-name.keystore -alias your-release-key-alias -keyalg RSA -keysize 2048 -validity 10000
keytool will ask for a set of information and generate a .keystore file in our folder
Copy the Keystore and paste it in Yourproject>android>app directory
Open Yourproject>android>gradle.properties in any code editor.
copy and paste the following lines below android.useAndroidX=true and replace the values
MYAPP_RELEASE_STORE_FILE=your-release-key-name.keystore
MYAPP_RELEASE_KEY_ALIAS=your-release-key-alias
MYAPP_RELEASE_STORE_PASSWORD=your-release-key-password
MYAPP_RELEASE_KEY_PASSWORD=your-release-key-password
Open build.gradle file under android/app
Add singing config like screenshot below
...
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
}
}
}
...
run following command in YourProject>android from the terminal
gradlew assembleRelease
Once completed we will have the .apk file ready in our app folder under android\app\build\outputs\apk\release