Generating an upload key: With keytool, you can create a private signing key. For Windows, keytool must be executed as administrator. After running this command, you will be asked for password for the keystore and key and Name fields for your key. The key store is then created as a file with the name. There is just one key in the keystore, and it is good for 10,000 days. Remember to write down the alias because you will need it later when signing your app.
If you’re not sure where your JDK bin folder is on macOS, run the following command: The JDK directory that is produced by this command will look something like this: Use the cd command to get to that directory, then run the keytool command with sudo access as following:
Setting up Gradle File:
- Put the my-upload-key.keystore file in your project folder\’s android/app directory.
- Add the following (replacing ***** with the right keystore password, alias, and key password) to the file /.gradle/gradle.properties or android/gradle.properties
These are going to be global Gradle variables, which we can later use in our Gradle config to sign our app. Adding signing config to your app’s Gradle config. The final configuration step is to set up release builds to be uploaded key-signed. In your project folder, edit the file android/app/build.gradle and add the following signing config.
Generating the release apk: After the configuration if you want to make release apk run the following command: And if you encounter any error then try this command: Generating the release AAB
After the configuration if you want to make release aab run the following command:
The created AAB, which is ready to be posted to Google Play, may be located under android/app/build/outputs/bundle/release/app-release.aab. Enabling Proguard to reduce the size of the APK (optional) Proguard is a tool that can slightly reduce the size of the APK.
To enable Proguard, edit android/app/build.gradle:
* Run Proguard to shrink the Java bytecode in release builds.