解决无法在[email protected]中安装Crosswalk插件

问题:

> cordova plugin add cordova-plugin-crosswalk-webview --save

Installing "cordova-plugin-crosswalk-webview" for android

Android Studio project detected

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 E:\mywork\ionic\cordova8\platforms\android\res\xml\config.xml failed)

    at EventEmitter.emit (events.js:185:19)

    at EventEmitter.module.exports.emit (C:\Users\lgh\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\events.js:71:17)

    at ConfigParser (C:\Users\lgh\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigParser\ConfigParser.js:34:16)

    at new module.exports (E:\mywork\ionic\cordova8\plugins\cordova-plugin-crosswalk-webview\hooks\update_config.js:37:25)

    at module.exports (E:\mywork\ionic\cordova8\plugins\cordova-plugin-crosswalk-webview\hooks\after_plugin_install\000-shared_mode_special.js:8:24)

    at runScriptViaModuleLoader (C:\Users\lgh\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:188:18)

    at runScript (C:\Users\lgh\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:164:16)

    at C:\Users\lgh\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:132:20

    at _fulfilled (C:\Users\lgh\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)

    at self.promiseDispatch.done (C:\Users\lgh\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)

(node:20348) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Unhandled "error" event. (Parsing E:\mywork\ionic\cordova8\platforms\android\res\xml\config.xml failed)

(node:20348) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

分析

文件platforms\android\res\xml\config.xml不存在(原因待进一步分析)

解决方法

方法一

使用cordova 7.0

方法二

https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview/issues/188

**[philoskim](https://github.com/philoskim)**

My workaround is as follows.

$ cordova -v

8.0.0

Modify the line 33--34 inyour_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'),

Modify the line 32 inyour_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()

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

I hope this solution will be helpful.

也可以修改文件
your_project/plugins/cordova-plugin-crosswalk-webview/platforms/android/xwalk.gradle

第32行

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

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

然后重新添加android平台
cordova platform rm android
cordova platform add android


你可能感兴趣的:(解决无法在[email protected]中安装Crosswalk插件)