By Sobhan


2015-09-12 05:37:12 8 Comments

I have added Crosswalk to my ionic project. When i do ionic build android it outputs two separate APK files, one for armv7 and one for x86.

However i want one single apk file bundling two architectures together.

I tried setting BUILD_MULTIPLE_APKS = false but it's still building two separate apks.

There is a post here saying :

Took me a minute but you can get the single build file by commenting out the cdvBuildMultipleApks=true line in the platforms/android/gradle.properties

Cheers

But i don't have any gradle.properties file in my platforms/android/ folder, i have a project.properties file and there is no cdvBuildMultipleApks=true line in it to comment out.

I tried to manually create a gradle.properties file and putting cdvBuildMultipleApks=false in there but still two outputs.

Any ideas how to achieve this?

Update:

My Cordova version is 5.1.1

Solution:

What did work for me as suggested by @mudasserajaz and here, was to :

  1. Create a file named build-extras.gradle inside my /platform/android/ directory.
  2. put ext.cdvBuildMultipleApks=false inside it.
  3. ionic build android --release then and Voila, it worked.

@mudasserajaz suggested the same thing except variable name is cdvBuildMultipleApks=false so in case it didn't work out for you, don't forget the ext

4 comments

@Mudasser Ajaz 2015-09-12 12:42:37

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.)

@Sobhan 2015-09-13 04:41:24

Creating build-extras.gradle in platforms/android/ and adding the line cdvBuildMultipleApks=false inside it worked like a charm!

@Sobhan 2015-09-13 07:22:19

Oh i realized my variable name inside build-extras.gradle was ext.cdvBuildMultipleApks=false. So in case the other one didn't work, don't forget the ext.

@Sobhan 2015-09-13 10:12:45

Regarding your update, to make separate builds, I deleted my build-extras.gradle file and again it made two separate files. So maybe just doing that or commenting the cdvBuildMultipleApks=false is enough.

@Mudasser Ajaz 2015-09-13 10:52:44

those are just my observations, which i faced on my system. Otherwise you are right, deleting file should be enough.

@FrancescoMussi 2016-08-10 16:46:52

This is still the way to do it? It is not working for me trying with both cdvBuildMultipleApks=false and ext.cdvBuildMultipleApks=false

@2xSamurai 2018-02-02 09:19:28

No need for this much hassle. The next answer does an even better job without making any new files. Also be sure to check @Henry Luo's answer as well. I ended up using the armv7 apk. When I combined both armv7 and x86, the size of the apk grew almost 3 times. stackoverflow.com/questions/32535551/… (link for the next answer in case it changes its positon)

@Henry Luo 2018-01-24 12:59:23

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.

@Alex G 2017-10-31 02:36:07

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.

@M. Junaid Salaat 2016-08-23 19:31:32

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

@Colin 2016-09-14 15:36:00

This worked for me. I'm using Visual Studio 2015 with a project created with Tools for Apache Cordova. I'm using Cordova CLI 5.4.1. I just added the preference to the <platform name="android"> section of my config.xml

@mg1075 2017-01-19 16:45:45

This also worked for me, except the <preference/> for xwalk was not part of my original config.xml.

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] Can't seem to generate an APK from ionic project

1 Answered Questions

[SOLVED] Crosswalk build one APK file only

1 Answered Questions

Ionic crosswalk configuration to build x86 apk

1 Answered Questions

[SOLVED] include crosswalk in combined armv7 x86 apk

1 Answered Questions

How can i come to know which apk will work on my devise in ionic?

2 Answered Questions

[SOLVED] cordova-plugin-crosswalk-webview on iOS

1 Answered Questions

Sponsored Content