Android 打包流程

1.找到路劲 node_modules\react-native\react.gradle 找到 doFirst,在这个下面添加

  doLast {
       def moveFunc = { resSuffix ->
       File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
          if (originalDir.exists()) {
               File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4")
               ant.move(file: originalDir, tofile: destDir)
            }
      }
     moveFunc.curry("ldpi").call()
     moveFunc.curry("mdpi").call()
     moveFunc.curry("hdpi").call()
     moveFunc.curry("xhdpi").call()
     moveFunc.curry("xxhdpi").call()
     moveFunc.curry("xxxhdpi").call()
}
image.png
  1. 找到路劲node_modules\react-native\local-cli\bundle\assetPathUtils.js 添加如下:
switch (scale) {
    case 0.75:
      return 'ldpi-v4';
    case 1:
      return 'mdpi-v4';
    case 1.5:
      return 'hdpi-v4';
    case 2:
      return 'xhdpi-v4';
    case 3:
      return 'xxhdpi-v4';
    case 4:
      return 'xxxhdpi-v4';
  }
image.png

3.在项目下面先运

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
  1. 生成之后要去文件夹删除如图(选中的文件删除即可):


    image.png

4.打开android studio, 打开项目里面的 android 目录如图:


image.png

如没有密钥可以先创建


image.png

创建的密钥请记住密码
image.png

点击下一步


image.png

第一个框是生成之后的打包文件
第二个是发布什么包
第三个可全部勾选
然后点击下一步。

注: 如果遇到一些问题,可以先 clean Project 然后再build Project。也可以先运行看项目能否跑起来。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一.APK相关 1.1 APK文件结构 我们简单把上面的内容分析一下: AndroidManifest.xml:清...
    小强大草莓阅读 8,545评论 0 1
  • summary 编译src文件,生成class文件 将class文件编译成为dex文件 编译资源文件(不包括ass...
    美乃滋酱啊阅读 5,055评论 0 1
  • 官方详细:https://ionicframework.com/docs/intro/deploying/ps:打...
    柳暗花明又一匪阅读 14,868评论 0 4
  • 《在风中骑行》 在风中骑行 任沂河大堤的猎猎长风 敲打我的头盔撞击我的耳鼓 呼呼作响 亲吻我的面庞抚摸我的全身 淋...
    神山仙翁阅读 981评论 0 2
  • 人,来到这世上,总会有许多的不如意,也会有许多的不公平;会有许多的失落,也会有许多的羡慕。 你羡慕我的自由,我羡慕...
    半朴园阅读 1,605评论 0 0