Current location - Quotes Website - Personality signature - How to package React native APK with Android Studio
How to package React native APK with Android Studio
Step one: sign.

Open Android Studio, click Build-> Generate Signed APK in the menu bar, and click Next in the opened interface to open the following interface.

Then click New and select the location, name and password of the key in the pop-up interface. Also write the name of the alias, the owner, country, organization and city of the certificate.

Note: the name of our app here is jd, and the alias is jd_alias. The passwords of the name and alias are the same.

Click OK to fill in the created signature information by default.

Finally, clicking finish will generate a signing key.

The second part:

The signature of the APP has been completed through the above steps! Let's start the real packaging!

1. Gradient configuration:

1. First, we need to copy the newly generated signature file to the android/app folder of the project (your xxx.jks file path may be different from mine, but it doesn't matter if you copy it to this andrid/app path).

Then modify the gradle.properties file in the project and add the following code (note that the names of the signatures and aliases below are the same as those of the test.jks put in the previous step, and the passwords of the signatures and aliases are filled in for the following two items respectively)-my password is ztt 12345.

In this step, we will configure the global gradlde in a variable way, and then sign the corresponding application in the following steps.

[Note]. Please take good care of the above signing key, because it is needed when the application is published.

2。 Add signature to application-configure Gradle file for local application.

Add the following contents directly to the following nodes in android/app/build.gradle under the project directory:

Note: the content here does not need to be modified! Just put it in the right place.

Finally, check whether there is a file named react.gradle (there will usually be init, see the specific path below).

All right! As long as you have this file ~ you can start packaging ~ enter the project root directory! (It is the root directory) Execute the following command:

Cd Android? & amp& amp? . /grad Lew assembler ease?

Then it will start packing ~ ~ (the packing time will be very long ~ ten minutes) and then the following figure will appear!

Ok ~ packaging is complete ~ ~

Then we will enter, and the file app-release.apk will be generated in the android/app/build/outputs/apk directory.

All right! You can publish it! One more thing! If you modify the file and repackage it, you can directly run the packaging command (cd android? & amp& amp? . /grad Lew assembler ease? ) without configuring anything else! ! ! !