【问题标题】:Strange gradle error Expected configuration (...) to contain exactly one file, however, it contains no files奇怪的gradle错误预期的配置(...)只包含一个文件,但是,它不包含任何文件
【发布时间】:2017-08-23 15:23:51
【问题描述】:

我正在尝试开发简单的即时应用程序。我已经完成了所有模块和配置,但是当我尝试立即运行时,gradle 控制台显示以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':blogspace-instant:packageDebugInstantAppBundle'.
> Expected configuration ':blogspace-instant:debugCompileClasspath' to contain exactly one file, however, it contains no files.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

有人知道如何解决这个问题吗?

【问题讨论】:

  • 你能提交一个错误,然后在这里链接到它吗?他们可能需要您提供可重现的项目。对大家都有帮助,谢谢! issuetracker.google.com/issues/…
  • 你可能想测试其他版本的插件到你的gradle插件,插件之间可能存在一些不兼容的问题。您可能想检查这个github issue,它通过检查插件的其他版本解决了同样的问题。希望这会有所帮助。
  • 也看到了这个问题,还没有解决办法。然而,在 O 迁移之前,我们的 IA 构建良好。如果我弄清楚了,我会回到这里。
  • 你解决了吗?
  • 这解决了我的问题:File-> Invalidate Caches/Restart

标签: android android-instant-apps


【解决方案1】:

确保在基本功能 defaultConfig 中有“baseFeature true”。

如果您没有基础且只有一项功能,请将 baseFeature 设置为您的一项功能。

在旧版本中,没有名称的功能是基础,但现在您需要明确标记一个。

【讨论】:

【解决方案2】:

如果您发现问题来自动态功能模块,请确保该问题取决于“基本”模块或您应用的任何模块:

apply plugin: 'com.android.application'

因为它将负责构建 Android 应用程序。

当动态功能开始发挥作用时,项目的构建方式发生了变化。在此之前,application 模块包含所有库模块,但现在动态功能模块需要包含 @ezio 提到的 application 模块:

https://stackoverflow.com/a/53916249/689723

【讨论】:

  • 这是文档中非常重要的一部分。很遗憾,Google 认为不适合将此花絮添加到他们的文档中。
【解决方案3】:

除了接受的答案中提到的内容外,我还必须做一件事才能使其正常工作。您必须确保所有功能模块都应依赖于基本模块。

把这个放到所有功能模块的gradle文件中

implementation project(':base')

【讨论】:

    【解决方案4】:

    确保您已将功能依赖项添加到 InstantApp 模块。

    这个解决方案对我有用。

    【讨论】:

      【解决方案5】:

      IDK 为什么,但这解决了我在使用dynamicFeatures 时遇到的上述问题

      错误

      Expected configuration ':features:auth:debugCompileClasspath' to contain exactly one file, however, it contains no files.
      

      问题

      implementation project(path: ':base-app', configuration: 'default')
      

      修复

      implementation project(":base-app")
      

      【讨论】:

        猜你喜欢
        • 2020-03-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-26
        • 1970-01-01
        • 1970-01-01
        • 2010-10-15
        相关资源
        最近更新 更多