【问题标题】:IllegalStateException: Expected configuration ':module:debugFeatureCompileClasspath' to contain exactly one file, however, it contains 2 filesIllegalStateException: 预期的配置 ':module:debugFeatureCompileClasspath' 只包含一个文件,但是,它包含 2 个文件
【发布时间】:2018-05-16 04:36:06
【问题描述】:

我正在使用具有即时应用程序和穿戴应用程序的多功能 android 应用程序。在这里我能够成功运行我的应用程序,但在 构建 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 个模块和一个基本模块项目。 我已经根据谷歌提供的示例集成了多功能即时应用程序的所有设置。 https://github.com/googlesamples/android-instant-apps/tree/master/multi-feature-module

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

  1. 应用模块

添加所有模块作为实现

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。接口模块

在 gradle 中添加了baseFeature true

这是我的一个 module1 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'

}

【问题讨论】:

  • 你能分享module1的build.gradle的相关部分吗?
  • 是的,用 module1 gradle 更新了问题。
  • 你在用什么com.android.tools.build:gradle?你能试试不同的版本吗? developer.android.com/studio/releases/gradle-plugin 搜索“只包含一个文件,但它包含 2 个文件。”与免安装应用无关,显示有些人使用不同的版本解决了这个问题。
  • 另外,您能否删除基本模块中重复的feature project(':module1')
  • 您的问题提到您在 apiModule 和 BaseModule 中都添加了 baseFeature true,这是真的吗?我认为您不能在同一个免安装应用中拥有 2 个基本功能。 apimodule 应该是一个普通的库模块,然后它将包含在您的 baseFeature APK 中。

标签: android kotlin android-instant-apps android-wear-2.0


【解决方案1】:

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

我所做的是将API模块的所有代码重构为基础模块,并仅使用baseFeature true制作一个基础模块

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-28
    相关资源
    最近更新 更多