Cordova + Crosswalk

Asked

Viewed 416 times

8

I created a normal Cordova project:

cordova create myApp com.myapp myApp

then I entered the project folder

cd myApp

added the platform:

cordova platform add android

and added the crosswalk plugin

cordova plugin add cordova-plugin-crosswalk-webview

If I import the project in Android Studio it gives me a package error. I searched and this error is because you need to compile the project for the crosswalk plugin download some classes etc... I tried to compile and:

cordova build android --release

The errors are gone, but it does not compile and gives several errors of duplicate classes...

C:\Users\GuilhermeAw\Desktop\teste\platforms\android\build\generated\source\r\x86\release\org\xwalk\core\R.java
Error:(9, 14) java: duplicate class: org.xwalk.core.R
C:\Users\GuilhermeAw\Desktop\teste\platforms\android\build\generated\source\r\x86\release\com\teste\R.java
Error:(10, 14) java: duplicate class: com.teste.R

If I delete the classes more errors appear:

Error:Android Dex: [android] Unable to execute DX
Error:Android Dex: [android] com.android.dex.DexException: Multiple dex files define Lorg/apache/cordova/AuthenticationToken;
Error:Android Dex: [android] at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:591)
Error:Android Dex: [android] at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:546)
Error:Android Dex: [android] at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:528)
Error:Android Dex: [android] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
Error:Android Dex: [android] at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
Error:Android Dex: [android] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
Error:Android Dex: [android] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Error:Android Dex: [android] at com.android.dx.command.dexer.Main.run(Main.java:277)
Error:Android Dex: [android] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:Android Dex: [android] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Error:Android Dex: [android] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error:Android Dex: [android] at java.lang.reflect.Method.invoke(Method.java:497)
Error:Android Dex: [android] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:188)
Error:Android Dex: [android] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:336)

I believe something is missing, but since it’s the first time I work with crosswalk I don’t know how to deal with these mistakes, someone knows what can be?

1 answer

1

I performed the steps you described but before adding the crosswalk lib I created inside the folder Platforms/android the file Gradle.properties, with the following content:

cdvMinSdkVersion=20

More details here.

Summarizing I followed the following steps:

npm install -g cordova

cordova create myApp com.myapp myApp

cd myApp

cordova platform add android

I created inside the folder Platforms/android the file Gradle.properties, with the following content:

cdvMinSdkVersion=20

cordova plugin add cordova-plugin-crosswalk-webview

cordova build android --release

Soon after I imported the project in Android Studio 3.0.1:

File > New > Import Project

I navigated to the directory of myapp/Platform and selected the folder Android and pressed Okay.

  • I wish it were easy so kkkk did not mess no... Dude this mistake haunts me for years and no one from anywhere knows how to solve.

  • What versions of your development environment items?

  • Until then everything is up to date...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.