Ionic 3项目和插件交叉错误

15

我有一个Ionic 3项目,当我运行"ionic cordova run android --prod"时,我看到了这个错误:

ANDROID_HOME=C:\Users\asus\AppData\Local\Android\sdk\ 
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131\  
Subproject Path: CordovaLib null 
The Task.leftShift(Closure) method has been deprecated and 
is scheduled to be removed in Gradle 5.0. Please use 
Task.doLast(Action) instead.
        at build_86b8k75dm7qqz7n5jyg9xp8kh.run(D:\project\ionic\MyProject\platforms\android\build.gradle:138) org.xwalk:xwalk_core_library:23+ The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.

Incremental java compilation is an incubating feature. The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInp uts.file(Object).skipWhenEmpty() instead.

FAILURE: Build failed with an exception.

* What went wrong:

BUILD FAILED

Total time: 15.644 secs A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_armv7DebugApkCopy'.
   > Could not resolve org.xwalk:xwalk_core_library:23+.
     Required by:
         project :
      > Could not resolve org.xwalk:xwalk_core_library:23+.
         > Failed to list versions for org.xwalk:xwalk_core_library.
            > Unable to load Maven meta-data from https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org /xwalk/xwalk_core_library/maven-metadata.xml.
               > Could not GET 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_ library/maven-metadata.xml'. Received status code 503 from server: Service Unavailable

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Error: cmd: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.

* What went wrong: A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_armv7DebugApkCopy'.
   > Could not resolve org.xwalk:xwalk_core_library:23+.
     Required by:
         project :
      > Could not resolve org.xwalk:xwalk_core_library:23+.
         > Failed to list versions for org.xwalk:xwalk_core_library.
            > Unable to load Maven meta-data from https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org /xwalk/xwalk_core_library/maven-metadata.xml.
               > Could not GET 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_ library/maven-metadata.xml'. Received status code 503 from server: Service Unavailable

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


[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova run android (exit code 1).

在运行 Ionic 之前,我没有收到过这个错误。

4个回答

27

01.org服务器似乎出现了问题。因此,在服务器恢复在线之前,您可以要求Gradle使用本地副本的Crosswalk。

我也遇到了同样的问题,持续了一个小时。下面的解决方案对我起了作用。

在您的项目目录中打开platforms\android\cordova-plugin-crosswalk-webview\*-xwalk.gradle文件,其中*是您的项目名称。

查找以下部分 -

dependencies {
    compile xwalkSpec
}

通过在开发者工具控制台中键入 window.navigator.userAgent,用您找到的 Chrome 开发者工具中的 Crosswalk 版本替换它。

因此,您最终的数据应该类似于这样 -

dependencies {
    compile 'org.xwalk:xwalk_core_library:23.53.589.4'
}

2
作为补充,还有另外两种方法可以获取xwalk_core_library版本,您可以选择其中之一:
    1. 进入platforms/android/build/intermediates/exploded-aar/org.xwalk/xwalk_core_library/,然后您可以看到类似于“19.49.514.5”的版本号。<br /> - 2. 在Google缓存中,您可以选择一个版本号。
- Zhongyuan Zhou
1
以上方法适用于32位构建,但对于64位构建(使用--xwalk64bit标志构建),它会创建API文件而不包括xwalk库。 - Alex Ryltsov
1
看起来将编译xwalkSpec更改为编译'org.xwalk:xwalk_core_library:22.52.561.4' + BIT_64对于64位构建起了作用。 - Alex Ryltsov

8

1 获取Crosswalk版本

有另外两种获取xwalk_core_library版本的方式,您可以使用其中任意一种:

  • 进入platforms/android/build/intermediates/exploded-aar/org.xwalk‌​/xwalk_core_library/目录,然后您可以看到形如19.49.514.5的版本号

  • Google缓存中,您可以选择一个版本号

2 更改Gradle文件

就像@hemantv所说,在文件platforms\android\cordova-plugin-crosswalk-webview*-xwalk.gradle

更改文件格式。

dependencies {
    compile xwalkSpec
}

为了

dependencies {
    compile 'org.xwalk:xwalk_core_library:19.49.514.5'
}

19.49.514.5是从步骤一获取的版本


另一种方法,您可以暂时使用此插件:

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

它刚刚修复了这个错误。

3

获取Crosswalk版本

正如Zhongyuan Zhou所回答的,有方法可以在项目中获取本地保存的Crosswalk库,但我更喜欢以下方法:

前往platforms/android/build/intermediates/exploded-aar/org.xwalk‌​/xwalk_core_library/‌,然后您可以看到版本号,例如22.52.561.4

修改config.xml

将以下内容添加到您的config.xml中

<preference name="xwalkVersion" value="xwalk_core_library:22.52.561.4" />

编译 Android 应用

使用 ionic cordova build android 命令编译 Android APK 文件,或者使用 ionic cordova run android 命令在模拟器或设备上构建、运行或安装 Android 应用。

参考链接:https://forum.ionicframework.com/t/server-error-with-crosswalk-when-running-ionic-run-android/104009/15


这是比修改平台的gradle文件更好的方法。 - Slartibartfast

1
这是对hemantv答案的跟进。我当时很慌乱,但他的回答拯救了我的一天,我成功使用本地存储的xwalk编译了应用程序。
以下是我所做的事情,希望能帮助那些陷入同样困境的人:
我通过在我的应用程序目录中运行搜索(包括子目录)"xwalk_core_library" 找到我本地存储的Crosswalk版本,并找到文件 "org.xwalk-xwalk_core_library-17.46.448.10_9bf812c8b76a44fdb31553d48df45b60d1362adc.jar",并确定我所拥有的版本是 "org.xwalk-xwalk_core_library-17.46.448.10"(下划线"_"后面的所有内容都不相关)。
我按照说明打开了 platforms\android\cordova-plugin-crosswalk-webview*-xwalk.gradle 文件,并找到了:
dependencies {
    compile xwalkSpec
}

被替换为

dependencies {    
    compile 'org.xwalk:xwalk_core_library:17.46.448.10'
}

尝试重新编译,结果非常顺利。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接