IllegalStateException: 预期配置“:module:debugFeatureCompileClasspath”只包含一个文件,然而,它包含 2 个文件

IllegalStateException: Expected configuration ':module:debugFeatureCompileClasspath' to contain exactly one file, however, it contains 2 files

我正在使用带有即时应用程序的多功能 android 应用程序并佩戴 app.Here 我能够 成功 运行 我的应用程序 但在 构建 APK 或重建项目 期间出现以下错误。

java.lang.IllegalStateException: Expected configuration ':module1:debugFeatureCompileClasspath' to contain exactly one file, however, it contains 2 files.
at org.gradle.api.internal.file.AbstractFileCollection.getSingleFile(AbstractFileCollection.java:62)
at com.android.build.gradle.tasks.MergeManifests.doFullTaskAction(MergeManifests.java:116)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)

我的项目有 3-4 个模块和一个基础模块项目。 我已经根据 google 提供的示例集成了多功能即时应用程序的所有设置。 https://github.com/googlesamples/android-instant-apps/tree/master/multi-feature-module

我有一个模块 (apimodule),我在其中添加了所有库和 API 依赖项。以下是我的项目依赖结构。

  1. AppModule

添加了所有模块作为实现

implementation project(':base')
implementation project(':module1')
implementation project(':module2')
implementation project(':module3')
wearApp project(':wear')
  1. BaseModule(还添加了 application project(':app')

在 gradle

中添加了 baseFeature true
feature project(':module1')
feature project(':module2')
feature project(':module3')
api project(':apimodule')

3。 api模块

在 gradle

中添加了 baseFeature true

这是我的一个模块 1 gradle 文件。

apply plugin: 'com.android.feature'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 26
    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation project(':base')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

}

根据我的问题,我在两个 gradle 文件中添加了 baseFeature true基础模块gradle和API模块之一gradle和API模块添加作为基础模块中的依赖项目。

我所做的是将API模块的所有代码重构到基本模块中,只制作一个基本模块 baseFeature true.

这是唯一解决我问题的案例。