我正在尝试开发简单的即时应用程序。我已经完成了所有模块和配置,但是当我试图立即运行时,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
有谁知道如何解决这个问题?
确保基本功能defaultConfig中有“baseFeature true”。
如果您没有基础且只有一个功能,请将baseFeature设为true。
在旧版本中,没有名称的功能是基础,但现在您需要对其进行explitly标记。
如果您发现问题来自动态功能模块,请确保此模块取决于“基础”模块或您应用的任何模块:
apply plugin: 'com.android.application'
因为它将成为负责构建Android应用程序的人。
当动态功能发挥作用时,项目的构建方式发生了变化。在此之前,application
模块包含了所有库模块,但现在动态功能模块需要包含application
模块,如@ezio所述:
除了接受的答案中提到的内容之外,我还需要做一件事才能使其发挥作用。您必须确保所有功能模块都应该依赖于基本模块。
将其放在所有功能模块的gradle文件中
implementation project(':base')
确保已向InstantApp模块添加功能依赖性。
这个解决方案对我有用。