Building combined armv7/x86 apk after Crosswalk integration in an Ionic project

末鹿安然 提交于 2019-11-27 06:44:20
Mudasser Ajaz

Here are steps to do that:

  1. Make a file build-extras.gradle and put it into platforms/android/. Add line cdvBuildMultipleApks=false into build-extras.gradle.
  2. Now run ionic run android, it will create combined single build android-debug.apk.

build.gradle will automaticaly import build-extras.gradle,if that is defined.You can see code of build.gradle doing this :

def hasBuildExtras = file('build-extras.gradle').exists()
if (hasBuildExtras) {
    apply from: 'build-extras.gradle'
}

Plus these instructions are clearly mentioned in build.gradle line 57 :

Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.

NOTE: Before you follow these steps, remove platform folder and install again.

Observations: Once you have done these steps, and again at some point, you want to make separate builds, then setting cdvBuildMultipleApks=true or commenting out sometimes won't work, you will simply have to install platform again. (P.S this is my personal observation, otherwise deleting build-extras.gradle should be enough.)

Well I just changed my config.xml following property to false and it combined the build apk.

from

<preference name="xwalkMultipleApk" value="true"/>

to

<preference name="xwalkMultipleApk" value="false"/>

My systems ionic info returns

Your system information:

Cordova CLI: 6.1.1
Gulp version:  CLI version 3.9.1
Gulp local:   Local version 3.9.1
Ionic CLI Version: 1.7.16
Ionic App Lib Version: 0.7.3
OS:
Node Version: v4.4.4

As of today, in 2018, we probably can ignore x86 mobile platform, as there's indeed hardly any mobile using Intel CPU.

This has the advantage of a smaller APK. A single-platform APK is smaller than the multi-platform APK.

Make sure to check the output folder.

I noticed that "cordova build" was still output both arm7 and x86 after adding to my build-extra.gradle but the output folder contained "android-release.apk" as well.

Deleting both arm7 and x86 APK's from the output folder (project/platforms/android/build/outputs/apk/)

it immediately stopped them from being shown by "corodva build".

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!