Win7 under react-native android packing step pit

Source: Internet
Author: User

It is said that tools make our use more convenient, but recently research react-native packaging and webpack These tools, really a sad tears. It feels like these development tools are very unfriendly to the window system, and foreigners are all using the Mac system's local tyrants.

To get to the point, write down this packaging process today, with the aim of helping those kids who work with me in the window system.

I will first introduce the complete process, and some of the problems and solutions that may be encountered

First, the complete packaging process
(1) Open Packager bag
/react-native start in the program root of cmd


(2) Execute mkdir android\app\src\main\assets in the project directory to store the later offline packages


(3) Generate key
Keytool-genkey-v-keystore Intelligentlifeandroid.keystore-alias intelligentlifeandroidalias-keyalg RSA under the program root of cmd -keysize 2048-validity 10000
The above Intelligentlifeandroid.keystore and Intelligentlifeandroidalias are modifiable


(4) Set the Gradle variable to place (3) The requested KeyStore file into the Android\app directory
Edit \ android \gradle.properties, add the following code (note: Please replace it with the replacement keystore password)

Myapp_release_store_file=my-release-key.keystore
Myapp_release_key_alias=my-key-alias
myapp_release_store_password=*****
myapp_release_key_password=*****


(5) Add signature to the app's gradle configuration file
Edit the Android/app/build.gradle in your project directory

...
Android {
...
Defaultconfig {...}
Copy: 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 {
...
Copy: Signingconfig signingconfigs.release
}
}
}

(6) CD to \android directory using Gradle command to sign the package: Gradlew assemblerelease
(Make sure react-native start is turned on before packaging)
After package success will be found in android\app\build\outputs\apk app-release.apk is the signature apk.

(7) If you want to repack, use the command in the \android directory: Gradlew clean (purge file)
(Make sure react-native start is turned on)
followed by the execution of command 6

(8) Once again after the execution of the package just direct execution (6) or (7)

Second, the packaging process may occur some problems:

1. View Gradle Environment
C:\Users\ user \.gradle\wrapper\dists's gradle2. The compression file of XX is complete or not

2. Reported: Java.util.zip.ZipException:error in opening zip file
The compilation environment is not the same as the JDK version of the build environment

3. Newspaper: ': App:bundlereleasejsandassets '
In the \android\app\react.gradle file
Before modification:
if (os.isfamily (os.family_windows)) {
CommandLine "cmd", "/C", "react-native", "bundle", "--platform", "Android", "--dev", "${devenabled}",
"--entry-file", Entryfile, "--bundle-output", Jsbundlefile, "--assets-dest", Resourcesdir
} else {
CommandLine "React-native", "bundle", "--platform", "Android", "--dev", "${devenabled}",
"--entry-file", Entryfile, "--bundle-output", Jsbundlefile, "--assets-dest", Resourcesdir
}


After modification:
if (os.isfamily (os.family_windows)) {
CommandLine "cmd", "/C", "Node", "Node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "Android", "-- Dev "," ${devenabled} ",
"--entry-file", Entryfile, "--bundle-output", Jsbundlefile, "--assets-dest", Resourcesdir
} else {
CommandLine "Node", "Node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "Android", "--dev", "${ devenabled} ",
"--entry-file", Entryfile, "--bundle-output", Jsbundlefile, "--assets-dest", Resourcesdir
}

Win7 under react-native android packing step pit

Related Article

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.