React Native Android to generate a signed APK

Source: Internet
Author: User

To publish your app via Google Play store or another channel, you'll need to generate a signed release APK package. The signature for your app in the Android developer documentation has been explained. This wizard will briefly describe these procedures and then focus on how to package JavaScript code.

Generate a signing key

You can use the keytool command to generate a private key.

Typing the following in the Command window

Keytool-genkey-v-keystore my-release-key.keystore -alias my-key-alias -keyalg rsa-keysize 2048-val Idity 10000

Note: The yellow label is the KeyStore file and the KeyStore alias, which is used in many places.

Note: Each time the apk is released,the content behind the KeyStore needs to be changed after the alias.

This command will ask you to enter the password for the KeyStore (keystore) and the corresponding key, and then set up some distribution-related information. Finally, it generates a KeyStore file called my-release-key.keystore .

After running the above statement, a separate key should have been generated in the KeyStore, valid for 10000 days. The alias after the--alias parameter is what you need to use to sign the app in the future, so remember to record the alias.

The project location where the generated KeyStore file is placed

To edit the ~/.gradle/gradle.properties, add the following code (note replace it with the corresponding password)

Myapp_release_store_file=my-release-key.keystore

Myapp_release_key_alias=my-key-alias

myapp_release_store_password=*****

myapp_release_key_password=*****

Note: Once you have published your app in the Play Store , if you want to change your signature, you must republish your app with a different package name. So be sure to back up your signature library and password .

Add a signature to the app's gradle config file #

To edit the android/app/build.gradlein your project directory, add the following:

...

Android {

...

Defaultconfig {...}

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

}

}

}

...

Build release APK Package

If you have a react.gradle under the Android/app ,

Just run the following command under Terminal:

$ cd Android &&./gradlew assemblerelease

After success

You should be able to find the generated apk file in android/app/build/outputs/apk/app-release.apk , and it can already be used for publishing.

React Native Android to generate a signed APK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.