Anything to think or worry about when switching Android app to Crosswalk?

My mobile app still uses the standard WebView on Android. I heard that Crosswalk improves that a lot, especially on older devices, since it is based on Chromium. And Meteor seems to make it easy since 1.2 to switch to Crosswalk, just by adding the respective package.

To those who already made the switch: Did you face any unexpected problems, or are there any things in particular to consider / test after the switch? Thanks.

We made the switch quite a while ago; great performance improvements. No real problems that I recall, but we did notice a significant increase in apk size (I think we went from ~4mb to ~20mb), I assume since you’re now bundling Chromium rather than using the native WebView. More than worth it though.

Thanks. I tried Crosswalk now, but the app crashed during installation on the device. I guess it is incompatible to one of my plugins.

Is there any way to debug these kind of crashes? I don’t get any output on the console, Meteor is still saying “Installing app on Android device”, and this runs forever after the app crashed.

You may have to remove the app from the device first after installing a new version with Crosswalk enabled.

Yes, I did this. But still it crashes on installation. :-/

Not sure if this helps, but have you tried running with --verbose to get more output?

Thanks for this tip. Yet it did not output anything valuable. Here’s the last lines I am getting:

Total time: 21.833 secs
Built the following apk(s):Device            /
    /Users/waldgeist/Documents/Development/htdocs/aiddogs/webapp/.meteor/local/cordova-build/platforms/android/build/outputs/apk/android-armv7-debug.apk
Using apk: /Users/waldgeist/Documents/Development/htdocs/aiddogs/webapp/.meteor/local/cordova-build/platforms/android/build/outputs/apk/android-armv7-debug.apk
Installing app on device...
Launching application...id Device 

And then the app crashes, and the build process stays on “Starting app on Android device”, with the spinner running.

BTW: Is there a way to exclude a Cordova plugin for a certain platform? I am using a plugin for WebRTC, which is not supported on iOS, but supported on Android per default. (Though this plugin does not seem to be the cause of my problem. The app crashes even if I omit this plugin.)

You can install plugins that only have support for certain platforms, but if it contains code for a platform there is no way to selectively disable it.

OK, thanks. I am now disabling one plugin at a time to find out which one might be causing the crashes. (I’m just guessing they are caused by plugins, though I do not use any fancy plugin besides WebRTC).

Surprisingly, after some additional test runs, I got a real error message:

=> Errors executing Cordova commands:         
                                              
   While running Cordova app for platform Android with options --device:
   Error: Command failed:                     
   /Users/waldgeist/Documents/Development/htdocs/aiddogs/webapp/.meteor/local/cordova-build/platforms/android/cordova/run
   --device
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   Note: Some input files use unchecked or unsafe operations.
   Note: Recompile with -Xlint:unchecked for details.
   

   /Users/waldgeist/Documents/Development/htdocs/aiddogs/webapp/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:126
   throw e;
   ^
   ERROR: Failed to launch application on device: ERROR: Failed to install apk to device:     pkg:
   /data/local/tmp/android-armv7-debug.apk
   Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
   at ChildProcess.exitCallback
   (/Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.1h955e4++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/utils/processes.js:150:21)
   at ChildProcess.emit (events.js:98:17)
   at Process.ChildProcess._handle.onexit (child_process.js:820:12)
   
                                              
ExitWithCode:1

Managed to start the app in Android Studio now, this shows:

01-21 15:12:30.522    1628-1628/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: io.guzz.mobileapp, PID: 1628
    java.lang.RuntimeException: Unable to start activity ComponentInfo{io.guzz.mobileapp/io.guzz.mobileapp.MainActivity}: java.lang.UnsupportedOperationException: setBackgroundColor
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:155)
            at android.app.ActivityThread.main(ActivityThread.java:5696)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
     Caused by: java.lang.UnsupportedOperationException: setBackgroundColor
            at org.xwalk.core.ReflectMethod.invoke(ReflectMethod.java:57)
            at org.xwalk.core.XWalkView.setBackgroundColor(XWalkView.java:608)
            at org.apache.cordova.CordovaActivity.createViews(CordovaActivity.java:186)
            at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:148)
            at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:220)
            at io.guzz.mobileapp.MainActivity.onCreate(MainActivity.java:32)
            at android.app.Activity.performCreate(Activity.java:5958)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:155)
            at android.app.ActivityThread.main(ActivityThread.java:5696)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

It worked after I removed this line from my mobile-config.js:

App.setPreference('BackgroundColor', '0xfff8e71d');

Seems to be a known issue: https://crosswalk-project.org/jira/browse/XWALK-5077

The INSTALL_FAILED_VERSION_DOWNGRADE message is actually expected (which doesn’t make it right, but apparently is how the Android SDK works) and can be solved by removing the app from de device.

Ah, yes, that is a known issue. Fixed in a more recent version of Crosswalk, upgraded to in Meteor 1.3.

Just Done the upgrade to crosswalk, and the performance improvement is amazing. 2 things

  • APK size when from 3.5mb to 54mb
  • and my touchmove events I had on my layout have suddenly become very laggy, still smooth, but start at least half a second after they should. - might create a separate forum post about this one.