There are instructions on how to do this in the official cordova crosswalk plugin.
Are you meaning - to integrate this into the Ionic CLI?
Hey, thanks for the link. I guess I was right. I'm new to the whole Google Play thing so I had problems understanding how to serve crosswalk for pre-Lollipop and normal for Lollipop devices. I did try to use minSdkVersion=21, but I did not test it properly.
This is my config.xml. Basically I never touch the /platforms/android folder, because ionic overwrites it each time you switch the browser. Note the android-versionCode="300" below, which is important for Google Play. Crosswalk gradle adds +2 for armv7 which is 3002 and +4 for x86 which is 3004. Now I'm guessing that Lollipop version should use higher version code, let's say 3006. Devices with Lollipop will use this one, others will skip to one of the crosswalk versions. Is this correct?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.climbuddy.mobile" version="0.0.3" android-versionCode="300" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Climbuddy</name>
<description>
Climbing application for creating interactive climbing guides.
</description>
<author email="[email protected]" href="http://climbuddy.com/">
Bojan Hribernik
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="6000"/>
<preference name="StatusBarOverlaysWebView" value="true"/>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
<platform name="android">
<preference name="android-minSdkVersion" value="16"/>
<preference name="android-targetSdkVersion" value="21"/>
<preference name="Fullscreen" value="true"/>
<!-- resources commented out -->
</platform>
<icon src="resources/android/icon/drawable-xhdpi-icon.png"/>
</widget>
I'm using two simple bash scripts to build. I'm sure there's a better way, but this is how I did it. It's not yet fully automated, I need to carefully change versionCode between steps. First I build crosswalk version with both x86 and armv7 apks and revert back. Then change versionCode manually in config.xml and build android.
First I run
./build_crosswalk.sh
#!/bin/bash
# add crosswalk
ionic browser add [email protected]
# now ionic replaces /platforms/android with the crosswalk version which uses gradle I believe
# copy release key and signing stuff to android platform to automate signing
cp platforms/android-files/cb-release-key.keystore platforms/android/
cp platforms/android-files/crosswalk/release-signing.properties platforms/android/
cp platforms/android-files/crosswalk/gradle.properties platforms/android/
# add plugins to update android manifest
# this will make sure that AndroidManifes.xml has all the right permissions
ionic plugin add com.brodysoft.sqliteplugin com.ionic.keyboard org.apache.cordova.file org.apache.cordova.file-transfer org.apache.cordova.splashscreen org.apache.cordova.network-information org.apache.cordova.statusbar https://github.com/ekuwang/cordova-plugin-statusbar
# build android app with crosswalk
ionic build --release android
# copy android crosswalk apks to build folder
cp platforms/android/build/outputs/apk/android-x86-release.apk build/android-pre-lollipop-x86.apk
cp platforms/android/build/outputs/apk/android-armv7-release.apk build/android-pre-lollipop-armv7.apk
# revert android crosswalk browser
ionic browser revert android
Then I manually change versionConfig from 300 to 3006 and run
./build_android.sh
#!/bin/bash
# revert android crosswalk browser
#ionic browser revert android
# copy android files to android platform
# normal android uses different settings for signing
cp platforms/android-files/cb-release-key.keystore platforms/android/
cp platforms/android-files/android/ant.properties platforms/android/
cp platforms/android-files/android/custom_rules.xml platforms/android/
cp platforms/android-files/android/secure.properties platforms/android/
# add plugins to update android manifest
ionic plugin add com.brodysoft.sqliteplugin com.ionic.keyboard org.apache.cordova.file org.apache.cordova.file-transfer org.apache.cordova.splashscreen org.apache.cordova.network-information org.apache.cordova.statusbar https://github.com/ekuwang/cordova-plugin-statusbar
# build android app without crosswalk
# how can I switch version code from 300 to 3006 here??
ionic build --release android -- --minSdkVersion=21
# copy android apk to build folder
cp platforms/android/ant-build/MainActivity-release.apk build/android-lollipop.apk
I end up with three files:
android-lollipop.apk
versionCode=3006
minSdkVersion=21
targetSdkVersion=21
android-pre-lollipop-x86.apk
versionCode=3004
minSdkVersion=16
targetSdkVersion=21
android-pre-lollipop-armv7.apk
versionCode=3002
minSdkVersion=16
targetSdkVersion=21
Is this ok? It would be so nice if ionic cli could handle this :)
This would be really great to have in the CLI.
@HriBB I wrote a script to increment the version code, but it looks like it's already doing it (lollipop version is outputting at XXXXX9 vs XXXXX2 for arm7 and XXXXX4 for x86.
android-versionCode="XXXXX" in your config.xml <widget> line#!/bin/bash
# add crosswalk
cordova plugin add cordova-plugin-crosswalk-webview
# build android app with crosswalk
ionic build --release android
# copy android crosswalk apks to build folder
cp platforms/android/build/outputs/apk/android-x86-release.apk /android-pre5-x86.apk
cp platforms/android/build/outputs/apk/android-armv7-release.apk /android-pre5-armv7.apk
# rm crosswalk
cordova plugin rm cordova-plugin-crosswalk-webview
# build android app without crosswalk
ionic build --release android -- --minSdkVersion=21
# copy android non-crosswalk apks to build folder
cp platforms/android/build/outputs/apk/android-release.apk /android-5.apk
@jbavari -- is this in the works at all? If not, I'll look at rewriting it into node and opening a PR when I have time.
Hello @dustinblanchard - I have the same need - build non-crosswalk for >=4.4 and crosswalk for <=4.4 - is the script above the latest?
Also, I assume you upload all of them to playstore using the multiple apk upload system?
Many thanks
@pliablepixels I actually haven't used Ionic in a few months, but that is the latest script I used. And yes, you upload each APK to the play store. You shouldn't have any issues since it was auto-numbering the versions.
Thanks @dustinblanchard!
+1 for this feature in cli itself. many of my clients don't want to download 25MB worth of apk if the android is latest version.
+1 Indeed.. day after day crosswalk is loosing the meaning to exist.. would be nice to have this in cli
I had an issue today and had a chat with google support and they recommend me to:
The target sdk must be equal for all, thats why it mught look wrong in crosswalk version where has a max19.
@mariohmol and you use the command line to achieve these 3 scenario's?
Or do you edit the config.xml before each build?
For example; should such line work for the first scenario?
ionic build --release android -- --minSdkVersion=21 --targetSdkVersion=23 --maxSdkVersion=25
And can't every file be the same version? i.e. v.2.0.0, because it should switch on the min/maxSdk right?
I'm going to close this, as Crosswalk is no longer maintained.
Most helpful comment
@HriBB I wrote a script to increment the version code, but it looks like it's already doing it (lollipop version is outputting at XXXXX9 vs XXXXX2 for arm7 and XXXXX4 for x86.
Dependencies:
android-versionCode="XXXXX"in your config.xml<widget>lineScript:
@jbavari -- is this in the works at all? If not, I'll look at rewriting it into node and opening a PR when I have time.