您是否尝试过以下方法?
implementation project(':androidLibrary')
根据 Google 的Migrate to Android Plugin for Gradle 3.0.0,“针对本地模块依赖项的特定变体(例如,使用配置:'debug')会导致以下构建错误:”
Error:Unable to resolve dependency for ':app@debug/compileClasspath':
Could not resolve project :library.
Error:Unable to resolve dependency for ':app@release/compileClasspath':
Could not resolve project :library.
我认为当您使用release
前缀releaseImplementation
和包含configuration: 'debug'
在此语句中时,您的目标是本地模块依赖项的特定变体:
releaseImplementation project(path: ':androidLibrary', configuration: 'debug')
它继续推荐以下解决方案:
“您应该按如下方式配置您的依赖项”:
dependencies {
// This is the old method and no longer works for local
// library modules:
// debugImplementation project(path: ':library', configuration: 'debug')
// releaseImplementation project(path: ':library', configuration: 'release')
// Instead, simply use the following to take advantage of
// variant-aware dependency resolution. You can learn more about
// the 'implementation' configuration in the section about
// new dependency configurations.
implementation project(':library')
// You can, however, keep using variant-specific configurations when
// targeting external dependencies. The following line adds 'app-magic'
// as a dependency to only the "debug" version of your module.
debugImplementation 'com.example.android:app-magic:12.3'
}
来源:迁移本地模块的依赖配置