Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactNative安卓打包失败&代码不更新的解决步骤 #10

Open
rico-c opened this issue Nov 15, 2018 · 0 comments
Open

ReactNative安卓打包失败&代码不更新的解决步骤 #10

rico-c opened this issue Nov 15, 2018 · 0 comments

Comments

@rico-c
Copy link
Owner

rico-c commented Nov 15, 2018

签名

首先,需要按照官方文档的步骤对app进行签名。

尝试打包

cd android进入安卓工程目录
./gradlew assembleRelease开始打包

这里可能会卡在:app:bundleReleaseJsAndAssets这个状态一直不动,这个时候直接control + c 放弃打包

首先我们在项目根目录下执行react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output App/src/main/assets/index.android.bundle --assets-dest App/src/main/res/
注意:

  1. 需要在根目录执行
  2. 根据版本不同,如果入口配置文件不是index.android.js,就改为相应的入口文件名,比如‘index.js’
  3. output的目录应为安卓的目录下,去生成index.android.bundle文件,如果目录因版本变化就修改为对应的路径

重新打包

处理好上面的步骤后,我们进入安卓的工程目录下,输入./gradlew assembleRelease -x bundleReleaseJsAndAssets尝试打包。

代码更新了APP没有变化?

这时我们应该发现APP已经打包成功了,但是安装在手机上后发现代码没有更新,这是因为每次打包前都需要生成一个新的index.android.bundle文件,这时我们需要进入安卓工程目录,进到/src/main/assets下删除旧的index.android.bundle文件,在重复执行react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output App/src/main/assets/index.android.bundle --assets-dest App/src/main/res/这个步骤,再尝试打包即可

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant