1. 在vs 终端执行:
yarn build
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle
2. 使用keytool.exe生成密钥
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
自己本机JAVA JDK路径: C:\Program Files\Java\jdk1.8.0_152\bin
3. 把在C:\Program Files\Java\jdk1.8.0_152\bin生成的文件my-release-key.keystore 复制到
E:\Jobs\PT\pt-civil-mobile\android\app 项目android/app下
4. 编辑 gradle.properties 文件: E:\Jobs\PT\pt-civil-mobile\android (复制下面内容)
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=123456
MYAPP_RELEASE_KEY_PASSWORD=123456
5. 修改文件 E:\Jobs\PT\pt-civil-mobile\android\app\ build.gradle
...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
}
}}...
6. cmd 中执行:
E:\Jobs\PT\pt-civil-mobile>cd android && gradlew assembleRelease
7. 生成路径: E:\Jobs\PT\pt-civil-mobile\android\app\build\outputs\apk, 参考视频:
https://www.youtube.com/watch?v=ywHiDReRSqg