crosswalk-project / cordova-plugin-crosswalk-webview

Crosswalk WebView Cordova Plugin (UNMAINTAINED)
https://crosswalk-project.org/blog/crosswalk-final-release.html
Apache License 2.0
945 stars 350 forks source link

Crosswalk with Cordova-Android 7.0 -> Failed to install 'cordova-plugin-crosswalk-webview': Error: Unhandled "error" event. (Parsing platforms/android/res/xml/config.xml failed) #188

Closed Bubelbub closed 6 years ago

Bubelbub commented 6 years ago

Hey guys,

I'm getting this error since few days.

Discovered plugin "cordova-plugin-crosswalk-webview" in config.xml. Adding it to the project
Installing "cordova-plugin-crosswalk-webview" for android
Subproject Path: CordovaLib
Subproject Path: app
        After much discussion and analysis of the market, we have decided to discontinue support for Android 4.0 (ICS) in Crosswalk starting with version 20.
        So the minSdkVersion of Cordova project is configured to 16 by default.

Failed to install 'cordova-plugin-crosswalk-webview': Error: Unhandled "error" event. (Parsing /bitrise/src/platforms/android/res/xml/config.xml failed)
    at EventEmitter.emit (events.js:186:19)
    at EventEmitter.module.exports.emit (/usr/lib/node_modules/cordova/node_modules/cordova-common/src/events.js:71:17)
    at new ConfigParser (/usr/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigParser/ConfigParser.js:34:16)
    at new module.exports (/bitrise/src/plugins/cordova-plugin-crosswalk-webview/hooks/update_config.js:37:25)
    at module.exports (/bitrise/src/plugins/cordova-plugin-crosswalk-webview/hooks/after_plugin_install/000-shared_mode_special.js:8:24)
    at runScriptViaModuleLoader (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:188:18)
    at runScript (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:164:16)
    at /usr/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:132:20
    at _fulfilled (/usr/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/usr/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:816:30)
Failed to restore plugin "cordova-plugin-crosswalk-webview" from config.xml. You might need to try adding it again. Error: Error: Unhandled "error" event. (Parsing /bitrise/src/platforms/android/res/xml/config.xml failed)

I'm using newest Android Cordova 7.0.0 and also tried with 6.3.

Do you know why this fails?

If I install this on my local computer (not on linux build machine) then everything works fine.

Bubelbub commented 6 years ago

I fout out that the path is wrong.

Thats the /bitrise/src/platforms/android folder.

2017-12-28 01_41_47

And here is the config.xml in res folder.

bitrise/src/platforms/android/app/src/main/res/xml/config.xml

Do you know why? Thanks :-)

mcfarljw commented 6 years ago

They changed the directory structure of cordova 7.0 so it probably won't work. It should be working with cordova 6.3.0 though. Make sure you clear everything before downgrading.

Bubelbub commented 6 years ago

Yes @mcfarljw you're right. I tried with cordova 7.0 and it works.

So I will change the title of this issue so that it can maybe be fixed. Normally I would say you not need crosswalk on newer android versions but the problem is that a lot of users using android with sdk 16, 17 or 18. I mean currently we have version 28 but a lot of devices not support this.

Don't know what the best solution is right now - except stay on 6.3.0. Hopefully there is not a big change to 7.0.

Maybe I start a new crosswalk branch for v7.

philoskim commented 6 years ago

My workaround is as follows.

$ cordova -v
8.0.0

1) Modify the line 33--34 in your_project/plugins/cordova-plugin-crosswalk-webview/hooks/update_config.js

//      platformConfigurationFile = path.join(androidPlatformDir,
//          'res', 'xml', 'config.xml'),
        platformConfigurationFile = path.join(androidPlatformDir,
            'app', 'src', 'main', 'res', 'xml', 'config.xml'),

2) Modify the line 32 in your_project/platforms/cordova-plugin-crosswalk-webview/*-xwalk.gradle

// def xml = file("res/xml/config.xml").getText()
def xml = file("src/main/res/xml/config.xml").getText()

3) After the modifications, I succeeded in $ cordova build android.

I hope this solution will be helpful.

jevian-ma commented 6 years ago

@philoskim Thank you, philoskim, you help me.

Marcophono2 commented 6 years ago

@philoskim: Perfect! :-)

periplox commented 6 years ago

Thanks @philoskim

hiroyui commented 6 years ago

Hi There i develope game for android and im new in this field, i have same trouble with @Bubelbub and i want to applied the @philoskim way, but the problem is when i open the js file in notepad it looks messy i can't decide which is line 33--34 or other, can you help me how i can modify it and know which correct line, thanks a lot

periplox commented 6 years ago

@hiroyui Why don't you try using a code editor like Sublime or VS Code? It'll help you to find the lines more easily. Anyhow, if you decide to stick with notepad you could search for the values (Ctrl + F), but then you need to be very careful and save a backup of the JS file before, in case something goes wrong.

hiroyui commented 6 years ago

@periplox thanks i'll try it

Marcophono2 commented 6 years ago

@hiroyui: Periplox is right. You just need a "better" text editor. That will let you see everything much more clear. There are a lot of text editors out there. Some are very professional for regarding language depending expressions but also very overload. I for example use Emeditor since years. That one also regards iE. Javascript and PHP programming styles but is easy to handle. (what a text editor should be of course ;)

Best regards Marc

joshstrange commented 6 years ago

I committed @philoskim's changes here https://github.com/corrisoft/cordova-plugin-crosswalk-webview

You can use it by running:

cordova plugin rm cordova-plugin-crosswalk-webview
cordova plugin add https://github.com/corrisoft/cordova-plugin-crosswalk-webview

Note you may need to copy over any config you may have set in package.json/config.xml such as XWALK_VERSION/XWALK_LITEVERSION/etc

Normally I would not suggest using a fork of a plugin like this but since Intel has dropped support for Crosswalk and I don't expect and new releases I think this is a decent approach.

PS: For those wondering why not just make @philoskim's changes locally: We need to build our apps on a CI server which is headless and needs to work without human intervention. There is a possibility of using some kind of cordova hook to make the above changes but this was faster and easier so I took this route.

SophiaSaiada commented 6 years ago

After I had made @philoskim 's changes I got this error when I'm launching the app: "Mismatch of CPU Architecture". Before I had updated to cordova 8 it worked well. Do you know how can I fix it? Thanks.

periplox commented 6 years ago

@yossi787 The same happened to me when I run cordova run android. It seems to work well with build, but then you have to upload and manually install the app. I failed to find a solution and ended up downgrading to version 7.1.0 (I needed to finish the job). If you find any solution please share it.

nprail commented 6 years ago

Now that the fix has been merged, will the fix be released soon? Or should I just add the plugin from the master branch?

baleboy commented 6 years ago

@nprail we would like to release it, but would first like to do some testing. However our testing resources are very limited, it would be great if you and anybody else who wants to help could test from master and report here the findings.

nbinand commented 6 years ago

Hello, Thanks for the fix, however it fails to detect cordova-android@7.0.0 in our config (Windows based). Some debugging leads to an issue with a trailing slash in var androidPlatformDir

Could I suggest some modification to the line 35 in update_config.js ?

Before:

if (fs.existsSync(androidPlatformDir + 'app/src/main/res/xml/config.xml')) {

After:

if (fs.existsSync(path.join(androidPlatformDir, 'app', 'src', 'main', 'res', 'xml', 'config.xml'))) {

With this little modification, we are now able to install plugin and build our app.

viniciusrc15 commented 6 years ago

i dont get it.. shouldnt this be open as this still an issue without solution? having exactly same error and could not fix it

ElNinjaGaiden commented 6 years ago

Hello all. I just added this plugin (including the change to fix the incompatibility problem with cordova-android 7) but now I'm not gettin separate/multiple apk's.

Any idea?