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)
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
I have one module(apimodule) where i have added all libraries and API dependencies. Following is my project dependencies structure.
- AppModule
Added all module as implementation
implementation project(':base')
implementation project(':module1')
implementation project(':module2')
implementation project(':module3')
wearApp project(':wear')
- BaseModule ( Also added
application project(':app')
)
Added baseFeature true
in gradle
feature project(':module1')
feature project(':module2')
feature project(':module3')
api project(':apimodule')
3. apimodule
Added baseFeature true
in 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'
}
com.android.tools.build:gradle
are you using? Could you try a different version? developer.android.com/studio/releases/gradle-plugin A search for "to contain exactly one file, however it contains 2 files.", unrelated to instant apps, shows some people resolved it with using a different version. – Serratofeature project(':module1')
in your base module. – SerratobaseFeature true
to both apiModule and BaseModule, is this true? I don't think you can have 2 base features in the same instant app. Theapimodule
should be a normal library module, then it will be shipped within your baseFeature APK. – Partook