IllegalStateException:预期配置':module:debugFeatureCompileClasspath'仅包含一个文件,但是,它包含2个文件 [英] IllegalStateException: Expected configuration ':module:debugFeatureCompileClasspath' to contain exactly one file, however, it contains 2 files

查看:451
本文介绍了IllegalStateException:预期配置':module:debugFeatureCompileClasspath'仅包含一个文件,但是,它包含2个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有即时应用程序和穿戴应用程序的多功能Android应用程序.在这里,我能够 成功运行我的应用程序 ,但是在 构建APK或重建项目 .

I am working with multi feature android application with instant app and wear app.Here i am able to successfully run my application but getting following error during building APK or rebuild projects.

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

My project has 3-4 module and one base module projects. I have already integrated all setup for multi feature instant app as per sample provide by google. https://github.com/googlesamples/android-instant-apps/tree/master/multi-feature-module

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

I have one module(apimodule) where i have added all libraries and API dependencies. Following is my project dependencies structure.

  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

Added baseFeature true in gradle

feature project(':module1')
feature project(':module2')
feature project(':module3')
api project(':apimodule')

3. apimodule

3. apimodule

在gradle中添加了baseFeature true

Added baseFeature true in gradle

这是我的一个module1 gradle文件.

Here is my one module1 gradle file.

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模块作为依赖项.

As per my question I have added baseFeature true in two gradle files. One of base module gradle and one API module gradle and API module added as dependency project in base module.

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

What I have done is that refactor all code of API module into base module and make only one base module with baseFeature true.

这只是案例解决了我的问题.

This is only case solved my problem.

这篇关于IllegalStateException:预期配置':module:debugFeatureCompileClasspath'仅包含一个文件,但是,它包含2个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆