【问题标题】:Building cordova-plugin-xapkreader with cordova-android 6.4.0使用cordova-android 6.4.0 构建cordova-plugin-xapkreader
【发布时间】:2018-05-03 14:32:59
【问题描述】:

我继承了一个使用cordova-plugin-xapkreader 的cordova 项目,它似乎是用于访问扩展(又名OBB)文件的标准插件。我遇到了一个问题,我希望它会影响其他cordova插件。运行cordova build android时出现以下错误:

Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Configuration 'compile' in project ':com.flyingsoftgames.xapkreader:downloader_library' is deprecated. Use 'implementation' instead.
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Configuration 'debugCompile' in project ':com.flyingsoftgames.xapkreader:downloader_library' is deprecated. Use 'debugImplementation' instead.
Configuration 'releaseCompile' in project ':com.flyingsoftgames.xapkreader:downloader_library' is deprecated. Use 'releaseImplementation' instead.
Configuration 'compile' in project ':com.flyingsoftgames.xapkreader:library' is deprecated. Use 'implementation' instead.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':debugCompileClasspath'.
   > Could not resolve project :com.flyingsoftgames.xapkreader:library.
     Required by:
         project : > project :com.flyingsoftgames.xapkreader:downloader_library
      > Project :com.flyingsoftgames.xapkreader:downloader_library declares a dependency from configuration 'debugCompile' to configuration 'debug' which is not declared in the descriptor for project :com.flyingsoftgames.xapkreader:library.

这已被其他人报告为插件论坛上的错误,但解决方法并不可靠:

https://github.com/agamemnus/cordova-plugin-xapkreader/issues/116

问题似乎是 gradle 希望您现在使用 implementation 而不是 compiledebugCompile 等。插件的 gradle 文件由 cordova 基于 cordova-android 中的模板生成。建议的解决方法是在从 cordova 挂钩运行的脚本中修改模板(或生成的 gradle 文件)。不幸的是,由于某种原因,这些钩子似乎不能可靠地工作 - 有时它们会,有时它们不会。这感觉可能是由于钩子与构建过程的其余部分异步运行导致的竞争条件 - 所以有时 gradle 构建在修改 gradle 文件之前就已经开始了。

有没有人知道如何正确解决这个问题?有谁知道为什么这不是 cordova-android 项目没有通过修改他们的模板来解决的更广泛的问题?我可以通过降级构建过程的某些部分来解决这个问题吗?

我对 Cordova 还是很陌生,所以这一切都很令人费解,非常感谢任何帮助!

【问题讨论】:

    标签: android cordova gradle


    【解决方案1】:

    不幸的是,由于某种原因,这些钩子似乎无法可靠地工作 - 有时他们会,有时他们不会。这感觉可能是由于钩子异步运行引起的竞争条件 与构建过程的其余部分一起 - 所以有时 gradle 构建有 在修改 gradle 文件之前启动。

    我认为这可以通过让钩子返回一个承诺来解决,这样你就可以确保构建的其余部分不会并行运行。我在 github 问题上发布了我正在使用的代码。

    相关代码如下:
    - 在钩子的开头创建一个promise:
    const deferral = context.requireCordovaModule('q').defer();
    - 在钩子结束时返回承诺:
    return deferral.promise;
    - 工作完成后(文件已写入)解决承诺:
    deferral.resolve();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-20
      • 2017-03-13
      • 2019-02-15
      • 2019-04-04
      • 1970-01-01
      • 2018-09-08
      • 2018-04-27
      • 2015-03-17
      相关资源
      最近更新 更多