Win7 platform under the react-native development of Android Project packaging release process

Source: Internet
Author: User

First, bundle files

One of the steps in the React-native development step is to use the command react-native start to start a node. JS-based service with the name Packager. The main functions of this packager are: 1, monitoring the current directory of the relevant file changes, 2, listening on the local 8081 (default) port, for the correct request to provide the appropriate bundle files. To sum up, the bundle files are dynamically generated according to the latest content of the corresponding files in the project directory, so that we can observe the changes in the program that we modify JS files in real time during the development process. Because this bundle file is the application logic of the last entire app, the key step for app packaging is how to package the bundle file as a generated static file into our app.

Second, packaging Step 1, Generate key
Keytool-genkey-v-keystore my-test-key.keystore-alias my-key-2048

The My-test-key.keystore and My-key-alias in the code are replaced with the required names. Remember that information such as the password entered in the next steps needs to be written for the Gradle script in step four.

2. Create Assets Folder

Create the Assets folder under the/android/app/src/main/directory under the project root directory

3. Get bundle files and save

First: Make sure you use the react-native Start command in the project root to start the packager, and you can use the browser test to get the bundle file correctly.

Then: Make sure you've installed the tool for curl or other tools of the same function.

Finally: in the project root directory, enter the following command:

" Http://localhost:8081/index.android.bundle "
4. Add Gradle keystore Configuration

Under the project root directory, under the/android/app directory, locate the Build.gradle file where you added:

//Add after Defaultconfig
Signingconfigs {release {storefilefile("/my-test-key.keystore")//Replace with your actual key file location Storepassword"the password in step 1"//Replace with your actual passwordKeyalias"My-key-alias"//ReplaceKeypassword"the password in step 1"//Replace}}//Modify the original configuration, the main is to join Signingconfig this line buildtypes {release {minifyenabled Enableproguardinreleasebuil DS//Remember to modify the corresponding function to startproguardfiles Fetdefaultproguardfile ('proguard-android.txt),'Proguard-rules.pro'signingconfig Signingconfigs.release}}

Note: the backslash (\) in the path is changed to a forward slash (/).

5. Enable Proguard code obfuscation (optional)

Proguard is a Java bytecode obfuscation compression tool that can be used to exclude parts of the project folder, effectively reducing the size of the APK. In the Build.gradle file, start the Proguard module:

True
6. Execute the packaging script

First: Enter the/android/directory under the project root directory;

Then: Execute the gradle assemblerelease command.

Note: If an error occurs or the Gradle tool is not installed, you need to install the Gradle tool yourself and configure the Gradle_home and PATH, note and/android/gradle/wrapper/ The version configuration in the Gradele-wrapper.properties file remains consistent. You can also use Gradle clean to clear the cache.

7. Publish apk to all major application markets

We can see our final release apk file in the/android/app/build/outputs/apk/directory.

  

Win7 platform under the react-native development of Android Project packaging release process

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.