Ionic - crosswalk and facebook plugin not working together?


#1

I created a brand new project today using the ionic framework:

ionic start myProject blank
ionic platform add android
ionic build android
ionic run android

Everything works fine so far.

I then add crosswalk

cordova plugin add cordova-plugin-crosswalk-webview
ionic build android
ionic run android

Everything runs fine so far.

I then add the phonegap facebook plugin

cordova -d plugin add /path/to/plugin --variable APP_ID=“123456789” --variable APP_NAME="myappname"
ionic build android

I get the following error:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)

FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithDexForArmv7Debug’.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘/usr/lib/jvm/java-7-openjdk-amd64/bin/java’’ finished with non-zero exit value 2

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

So it looked like the plugin might be wrong, so I removed crosswalk to see if without crosswalk the plugin still didn’t work:

ionic browser rm crosswalk
ionic build android
ionic run android

To my surprise it worked. The app ran with no errors. So it then seems that if crosswalk and the facebook plugin are together it doesn’t work? Has anyone experienced this previously? I ask because crosswalk and the Facebook plugin are quite popular so I assume someone has.

Cheers


#2

If somebody finds out a solution to this compability problem, I’m also interested in hearing the workaround! Any ideas, anyone?


#3

I looked into this for a couple of weeks with no success. Crosswalk has this as a known issue (https://crosswalk-project.org/jira/browse/XWALK-2892), but the ticket was created in 2014 and no work has been done on it. I contacted them weeks ago about this ticket, but never received a response. I would not count on this being fixed by Crosswalk and most likely will need to be fixed ourselves. Many people face a similar problem, some solutions work for some, but I was not able to get any to work for me.

PS the person who the ticket is assigned to is an inactive user.


#4

Good points. Btw, I found a possible solution, and I’m playing around with it right now: https://github.com/machei/phonegap-facebook-crosswalk-plugin


#5

Hooray! I have now succesfully built an APK with Crosswalk + Facebook plugin combination. Using cordova-plugin-crosswalk-webview instead of crosswalk browser seems to solve the problem.

It’s important to notice, that you need to use cordova-plugin-crosswalk-webview version 1.2.0 since newer versions do build but crash in the launch. The combination I can confirm to work is cordova-plugin-crosswalk-webview@1.2.0 and phonegap-facebook-plugin@0.12.0.

So, to fix your shit, make sure you don’t have any Crosswalk-related stuff installed, and run the following to add proper version of Crosswalk support.

cordova plugin add cordova-plugin-crosswalk-webview@1.2.0

After that you should be able to run ionic run android and ionic build android as you would normally do.


#6

Man you’re genius! did it this way and it built successfully… I think it has to be with the android support version… It seems that a newer version will have android-support-v13.jar but phonegap-facebook-plugin still uses android-support-v4.jar… anyways, it did the damn trick, thanks!


#7

Try this:

cordova plugin rm cordova-plugin-crosswalk-webview
cordova plugin add cordova-plugin-crosswalk-webview@2.2.0

It´s work for me