How to Generate signed or released apk file from react-native

Ragu Developer
2 min readApr 24, 2019

--

What is Apk:

  • Android package kit (Apk) is the package file format used by the Android operating system for distribution and installation of mobile apps and middleware.
  • Apk files are compressed all format files.
  • Apk file extension file_name.apk

What is Signed Apk:

  • An Android app will execute in debug mode in the development environment, i.e. while running in the Android Studio Integrated Development Environment (IDE).
  • The signed apk must be disabled the debug logging, StrictMode and the debugging options.
  • The signed apk only ready for releasing to the app stores.

How to build signed apk:

Step 1: Find keytool executable file. The java folder have the keytool file

Location : /usr/lib/java/jdk1.8.0_131/bin/keytool

Open command prompt in keytool file path and enter this command lines.

keytool -genkey -v -keystore ENTER_APP_Name.keystore -alias ENTER_APP_Alias_Name -keyalg RSA -keysize 2048 -validity 10000

Step 2: Set password and enter organizations details. The details are shown in image.

if the details are entered , the keystore file will be generate in keytool file path. The file will be generate in app_name.keystore file.

Step 3 : Move to the app_name.keystore this path.

Your_project/android/app/app_name.keystore

Step 4 : open build.gradle file.

Your_project/android/app/build.gradle

The defaultConfig add below to signingConfigs.

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

Step 5: open build.gradle file and find buildTypes and add this line

signingConfig signingConfigs.release

Step 6: open gradle.properties file.

Your_project/android/gradle.properties

add this,

MYAPP_RELEASE_STORE_FILE = ENTER_app_name.keystore
MYAPP_RELEASE_KEY_ALIAS = ENTER_app_alias_name
MYAPP_RELEASE_STORE_PASSWORD = ENTER_Password
MYAPP_RELEASE_KEY_PASSWORD = ENTER_Re_Password

Step 7: Go to Your_project/android path.

run this command,

./gradlew assembleRelease

Step 8: Now we will get signed apk in this path ,

Your_Project/android/app/build/outputs/apk/release/app-release.apk

Note : Once if generate keystore file next time not need to generate keystore file. next time you should change versions and follow the step 7.

Thank you,

--

--