Step-by-Step Guide to Generating a Signed APK in React Native Using Android Studio and Terminal

Shravan Meena
3 min readJun 7, 2023

Are you ready to unleash your amazing React Native app on the Google Play Store? 📱💥 The process of publishing an app can seem daunting, but fear not! In this guide, we will walk you through each step, providing clear instructions and commands to ensure a successful journey. Let’s dive in and make your app shine on the Google Play Store! 🚀🌟

Step 1: Generating an Upload Key 🗝️ First things first, let’s generate a private signing key using the keytool utility. This key will be used to sign your app before uploading it to Google Play. Depending on your operating system, use the appropriate command below:

Windows:

keytool -genkeypair -v -storetype PKCS12 -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

macOS:

sudo keytool -genkey -v -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

Remember to keep your keystore file private and secure! 🤫🔒

Copy your “my-upload-key.keystore” file and move it into the “/android” directory, follow these steps:

  1. Locate your “my-upload-key.keystore” file in the directory where you generated it.
  2. Copy the file to your clipboard.
  3. Open the file explorer or terminal and navigate to your React Native project’s root directory.
  4. Inside the root directory, you’ll find the “android” folder.
  5. Paste the “my-upload-key.keystore” file into the “android” folder.

By moving the “my-upload-key.keystore” file into the “/android” directory, you ensure that it is in the correct location for signing your app during the build process.

Step 2: Setting up Gradle Variables 📝 Now, let’s configure Gradle to use your upload key. Locate the gradle.properties file in your project directory and add the following lines, replacing the placeholders with your actual key details:

MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=*****
MYAPP_UPLOAD_KEY_PASSWORD=*****

By adding these variables, Gradle will know how to sign your app during the build process.

Step 3: Adding Signing Config to Gradle ✍️✨ To ensure that your release build is signed correctly, open the android/app/build.gradle file and add the signing configuration inside the android block. Use the following code snippet:

android {
// ...
signingConfigs {
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
buildTypes {
release {
// ...
signingConfig signingConfigs.release
}
}
}

Step 4: Generating the Release AAB or APK 🚀🎁 Now, it’s time to generate the release APK using Android Studio’s terminal. Follow the steps below:

  1. Open Android Studio.
  2. In the toolbar at the bottom, click on “Terminal” to open the terminal window.
  3. Navigate to the project’s root directory using the cd command.
  4. Run the following command to generate the release APK:
./gradlew assembleRelease

Wait for the build process to complete. Once finished, you’ll find the generated APK file in the android/app/build/outputs/apk/release directory.

Step 5: Testing the Release Build ✅🔍

Before submitting your app to the Google Play Store, it’s crucial to test the release build thoroughly. Uninstall any previous versions of the app from your device and then install the release build using the following command in the project root:

npx react-native run-android --variant=release

Make sure to terminate any running bundler instances, as all the necessary JavaScript code is bundled in the APK or AAB.

Step 6: Publishing to the Google Play Store 🌐📲 The moment has arrived! Head over to the Google Play Console and follow these steps:

  1. Create a new application listing.
  2. Provide captivating app descriptions and engaging screenshots.
  3. Upload your release AAB or APK file.
  4. Fill in the necessary details, such as pricing and distribution options.
  5. Review all the information carefully and hit that “Publish” button!

Congratulations! Your app is now on its way to reaching millions of Android users on the Google Play Store. 🚀🌍🎉

Conclusion: Publishing your React Native app on the Google Play Store is an exciting milestone on your app development journey. By following these step-by-step instructions and using the provided commands, you can confidently navigate the publishing process. Embrace the opportunity to share your app with the world and watch it thrive in the Android ecosystem! 📲🌟🚀

--

--

Shravan Meena

Writing code is my passion. I firmly believe in the transformative and enhancing power of programming, and how it can improve the lives of those around world.