weex转android踩坑之旅

weex转android踩坑之旅

  1. 编译代码

    • weex platform add android

    • weex build android

      // 坑
      // 在build时报错,未找到ANDROID_HOME
      // 原因: 在~/.bash_profile 里将ANDROID_HOME暴露出来
      export ANDROID_HOME=/Users/yanglin/Library/Android/sdk // 个人路径不同,自行寻找sdk位置
      export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
      
  2. 使用AS载入项目

    • 修改build.gradle里的参数与当前环境配置的一样,具体配置可新建android项目查看

    • 同时gradle文件替换

    • 运行项目

      // 坑
      /* 在AS 3.1.4中出现 
          1. Cannot set the value of read-only property ‘outputFile’ for ApkVariantOutputImpl_Decorated 
          2. Absolute path are not supported when setting an output file name
      */
      
      // 这是原本的代码
      applicationVariants.all { variant ->
          variant.outputs.each { output ->
              def outputFile = output.outputFile
              if (outputFile != null && outputFile.name.equals('app-debug.apk')) {
                  def fileName = outputFile.name.replace("app-debug.apk", "weex-app.apk")
                  output.outputFile = new File(outputFile.parent, fileName)
              }
          }
      }
      
      // 修改后的代码
      applicationVariants.all { variant ->
          variant.outputs.all { output ->  // 此处的each 变为 all
              def outputFile = output.outputFile
              if (outputFile != null && outputFile.name.equals('app-debug.apk')) {
                  def fileName = outputFile.name.replace("app-debug.apk", "weex-app.apk")
                  outputFileName = new File("../../../release/", fileName)
                  // 此处变为相对路径 以及 output.outputFile 变为 outputFileName
              }
          }
      }
      
      // 再次运行后出现
      // Annotation processors must be explicitly declared now
      // 原因:版本问题
      // 在build.gradle中的defaultConfig中添加
      javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } }
      
  3. 成功在真机上运行

    • 但是又出现 weex render error: -2013

      // 巨坑
      // 原因: js包有问题
      // 突然发现使用weex create 创建的项目引入vuex导致安卓报错
      // Exception: TypeError: undefined is not an object (evaluating 'this.$store.getters')
      // 求助大牛给我解答一下。。。
      

彻底弃坑,没有任何办法!!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值