I’m working on a Ionic project which is deployed to mobile devices via Cordova. For performance and compatibility, I introduced Crosswalk, which is a library embedding a Chrome into the app.
It’s working great and as expected. There is only one problem: the size is too big. It comes about 20MB for each architecture, so ARM and x86 need 40MB, while my app itself is only 10MB.
Fortunately, with Crosswalk-lite, the library size can be reduced by ~50%. The price is disabled features, and decompression at the first time of boot after installed. On my old Galaxy Nexus, the decompression takes ~20 seconds.
Crosswalk-lite seems in immature state, lacking customizations, including the ability to set the title and content of the prompt during the decompression, which is important to me that I want to comfort the users, using Chinese.
I followed the instruction, and successfully compiled a library with customized decompression prompt. I’m writing down some outdated steps, and missing caveats.
--no-history
parameter to get a shallow clone, so it’s much smaller.build/install-build-deps-android.sh
for more dependencies.@origin/crosswalk-lite
).target_arch=ia32
generates a library with both ARM and x86 support, setting target_arch=arm
generates a library with only ARM support).IDS_CROSSWALK_INSTALL_TITLE
and IDS_DECOMPRESSION_PROGRESS_MESSAGE
in runtime/android/core/strings/xwalk_app_strings.grd
.ninja -C out/Release xwalk_core_library
, and ninja -C out/Release xwalk_core_library_aar xwalk_shared_library_aar
. It took 0.5~1 hour in my VPS. (The aar
file seems just a zip file, so to combine different architectures, unzip, copy, and zip again should do, according to XWALK-1930).xwalk_core_library.aar
in src/out/Release
.mvn install:install-file
to install xwalk_core_library.aar
into local mvn repository. The version is specified in parameters and will be used later.config.xml
of the Ionic project, update xwalkVersion
to the version we just made up and used.platform/android
, edit cordova-plugin-crosswalk-webview/xxx-xwalk.gradle
, find repositories
block, and add mavenLocal()
. (The cordova doc is wrong, the url should not be deleted.) It’s likerepositories {
maven {
url xwalkMavenRepo
}
mavenLocal()
}
and the dependencies
block, with the full version info.
dependencies {
compile 'org.xwalk:xwalk_core_library_canary:(version without parenthese)'
}
Build and install the apk.
<preference name="loadUrlTimeoutValue" value="60000" />
seems necessary in config.xml
, otherwise, the decompression will use up the time and the page won’t load, though it’ll work in next boot.
TODO:
cordova-plugin-crosswalk-webview
needs work to support customized libraries.