如何使用ionic-cli构建带有Crosswalk lite的Android? [英] How to build android with Crosswalk lite using ionic-cli?

查看:586
本文介绍了如何使用ionic-cli构建带有Crosswalk lite的Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Crosswalk( ionic browser add crosswalk; ionic build android )编译APK时,大小太大(〜20 MB)。我认为使用crosswalk精简会减少编译APK的大小。但我不知道如何使用crosswalk lite ionic-cli 。 / p>

我的问题是:
1.这会支持crosswalk lite吗?
2.使用crosswalk lite是否有任何hack(或临时解决方案)?



谢谢。

解决方案

这是实验性的,但它会工作,无法保证在您构建应用程序时没有错误,请阅读
$ b。

$ b

过程:(所有步骤均从运行MS-Windows 8.1的计算机完成)


  1. 首先,我已经搜索可用的crosswalk-lite从哪里下载版本,看起来只有3个可用版本下载 这里 ,可以看到最新的 10.39.234.1 我试过以后的版本,如12.xx,13.xx和14.xx,但徒劳,找不到任何回购的更高版本。


  2. 导航到您的npm node-modules文件夹:Windows中的默认值为





C:\Users\ @ YOUR_USER_NAME\AppData\Roaming\\\
pm\\\
ode_modules


找到离子模块文件夹,然后开始编辑browser.js文件,文件可以在里面找到:


node_modules\ionic\lib\ionic \browser.js





  1. 在代码编辑器中找到第169行:

  IonicTask.prototype.downloadCrosswalkWebview = function downloadCrosswalkWebview(architecture,version,releaseStatus){...}  



这个函数负责下载你想要的crosswalk版本,它需要以下参数:


architecture,version和releaseStatus。 / p>

我们将手动添加我们的lite版本,以便稍后下载。



我们将暂时更改某些值,以便下载精简版,但稍后将其恢复为原始值:



在第178行:



更改



  var downloadUrl ='https://download.01.org/crosswalk/releases/crosswalk/android/'+ releaseStatus +'/'+ version +'/'+ architecture +'/ crosswalk-webview-'+ version +' - '+ architecture +'.zip';  



  var downloadUrl ='https://download.01.org/crosswalk/releases/ crosswalk-lite / android /'+ releaseStatus +'/'+ version +'/'+ architecture +'/ crosswalk-webview-'+ version +' - '+ architecture +'.zip';  

p>


  1. 对象 crosswalkVersions ,将此对象添加到其中:

  {version:'10 .39.234.1',publish_date:'2015-03-06 03:06',canary:true}  



您可以在CLI中测试该对象是否已成功运行此命令:

 离子浏览器列表

您可以看到它列在可用的版本:


  1. 最后一步是通过CLI命令将您的crosswalk-lite项目下载到项目文件夹中:



    1.   ionic browser add crosswalk@10.39.234.1  pre> 



      这是你所做的一切。



      PS:



      我从未尝试过建立我的混合项目。


      When I compile APK using Crosswalk (ionic browser add crosswalk; ionic build android), the size is too big (~20 MB). I think using crosswalk lite will reduce the size of compiled APK. But I have no idea to hack ionic-cli to use crosswalk lite.

      My question is: 1. Will this support crosswalk lite? 2. Is there any hack (or temporary solution) to use crosswalk lite?

      Thanks.

      解决方案

      This is experimentary , but it will work , cant guarantee there will be no bugs when you build your app though , please read this well before you proceed.

      Procedure : ( all steps are done from a machine running MS-Windows 8.1)

      1. First of all, I have searched for available crosswalk-lite everywhere to download the version from , it appears that there are only 3 available versions to download found here , and as you can see the latest is 10.39.234.1 i tried later versions like 12.xx , 13.xx , and 14.xx but in vain , could not find any repo for later versions.

      2. Navigate to your npm node-modules folder : default in windows is

      C:\Users\@YOUR_USER_NAME\AppData\Roaming\npm\node_modules

      find the ionic module folder , and then , and start editing browser.js file , file can be found inside:

      node_modules\ionic\lib\ionic\browser.js

      1. In your code editor find the line #169 :

      IonicTask.prototype.downloadCrosswalkWebview = function downloadCrosswalkWebview(architecture, version, releaseStatus) {
        .....
      
      }

      this function is responsible for downloading the crosswalk version you want , and it takes the following parameters :

      architecture , version and releaseStatus.

      We will be adding our lite version manually , so we can download it later.

      We will be changing some value temporarily for downloading lite version , but remmeber to turn it back to its original value later :

      in line#178 :

      change

       var downloadUrl = 'https://download.01.org/crosswalk/releases/crosswalk/android/' + releaseStatus + '/' +
          version + '/' + architecture + '/crosswalk-webview-' + version + '-' + architecture + '.zip';

      to be :

       var downloadUrl = 'https://download.01.org/crosswalk/releases/crosswalk-lite/android/' + releaseStatus + '/' +
          version + '/' + architecture + '/crosswalk-webview-' + version + '-' + architecture + '.zip';

      1. in line#39 there is an array of objects crosswalkVersions , add this object to it :

      {
        version: '10.39.234.1',
        publish_date: '2015-03-06 03:06',
        canary: true
      }

      You can test that object is added successfully running this command in your CLI :

      ionic browser list
      

      and as you can see it got listed in available versions:

      1. Final step is to download your crosswalk-lite project into your project folder via CLI Command :

        ionic browser add crosswalk@10.39.234.1

      That is all you are done.

      P.S:

      I have never tried ionic in building my hybrid projects.

      这篇关于如何使用ionic-cli构建带有Crosswalk lite的Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆