我认为您可能忘记了基本模块中的 baseFeature 标签。如果您有一个基本模块和 2 个功能模块作为示例,您的 gradle 应该如下所示(您需要注意正确的插件、baseFeature=true 标记和正确的依赖项声明)。
基本模块Gradle 文件:
apply plugin: 'com.android.feature'
android {
//this is mandatory for the base module of the project
baseFeature = true
...
}
dependencies {
...
feature project(':feature1')
feature project(':feature2')
application project(':hello-installed')
}
Feature1 模块和Feature2 模块Gradle 文件:
apply plugin: 'com.android.feature'
android {
...
}
dependencies {
...
implementation project(':base')
}
Instant App 模块Gradle 文件:
apply plugin: 'com.android.instantapp'
dependencies {
implementation project(':base')
implementation project(':feature1')
implementation project(':feature2')
}
完整的应用模块Gradle 文件:
apply plugin: 'com.android.application'
android {
//classic gradle declaration for legacy apps
}
dependencies {
implementation project(':base')
implementation project(':feature1')
implementation project(':feature2')
//non instant libraries will only appear here
implementation project(':nonInstantLibrary')
}
非即时兼容的模块Gradle 文件:
//it will use the legacy library plugin
apply plugin: 'com.android.library'
dependencies {
...
implementation project(':base')
}