React Native items packaged offline Android apk
1, generated signature key
1): Perform generate command (need to be performed under jdk bin directory)
#生成命令
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
2): Fill in the area of information and
3): key generation is completed there will be a my-release-key.keystore key store file
![Here Insert Picture Description](https://img-blog.csdnimg.cn/2019011515032688.png)
2, the global variable configuration gradle
- Creating gradle.properties file \ Users \ username under \ .gradle, add the following: in C:
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=您设置的密码
MYAPP_RELEASE_KEY_PASSWORD=您设置的密码
![Here Insert Picture Description](https://img-blog.csdnimg.cn/2019011514583981.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDE4NzczMA==,size_16,color_FFFFFF,t_70)
3, give yourself an RN configuration signature project
1): The signature file my-release-key.keystore on, react android native project \ app down.
![Here Insert Picture Description](https://img-blog.csdnimg.cn/20190115145927545.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDE4NzczMA==,size_16,color_FFFFFF,t_70)
2): edit android / build.gradle file in the app, add the following:
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 {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
![Here Insert Picture Description](https://img-blog.csdnimg.cn/20190115150025257.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDE4NzczMA==,size_16,color_FFFFFF,t_70)
3): edit android / gradle.properties file, add the following:
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=您设置的密码
MYAPP_RELEASE_KEY_PASSWORD=您设置的密码
![Here Insert Picture Description](https://img-blog.csdnimg.cn/20190115150128447.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDE4NzczMA==,size_16,color_FFFFFF,t_70)
4, packing APk
- After the package will apk android / app / build / outputs / apk directory in
#进入安卓目录
cd android
#清理缓存
gradlew clean
#执行打包
gradlew assembleRelease
![Here Insert Picture Description](https://img-blog.csdnimg.cn/20190115150231701.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDE4NzczMA==,size_16,color_FFFFFF,t_70)