Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot choose between the following variants of project :features:myDynamicFeatureModule:

I am experimenting with Android's Dynamic Feature Modules (a.k.a. on demand modules) on the side of the project I am working on.

In my PoC (proof-of-concept) project, Dynamic Feature Modules (DFM) work fine and gradle builds the project with no issue. After finishing with my PoC, I decided to apply it to an existing project. However, gradle failed building the project with:

Could not determine the dependencies of task ':my-app:checkSomeBuildFlavorDebugLibraries'.

> Could not resolve all task dependencies for configuration ':my-app:someBuildFlavorDebugMetadataValues'.
   > Could not resolve project :features:myDynamicFeatureModule.
     Required by:
         project :my-app
      > Cannot choose between the following variants of project :features:myDynamicFeatureModule:
          - anotherBuildFlavorDebugAndroidTestCompile
          - anotherBuildFlavorDebugAndroidTestRuntime
          - ...
        All of them match the consumer attributes:

          - Variant 'anotherBuildFlavorDebugAndroidTestCompile' capability myproject.features:myDynamicFeatureModule:unspecified:
              - Unmatched attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Metadata' but no value provided.
                  - Required endpoint 'someBuildFlavor' but no value provided.
                  - Found org.jetbrains.kotlin.localToProject 'local to :features:myDynamicFeatureModule' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'androidJvm' but wasn't required.
          - Variant ...

Note that this error is quite long, iterating through all possible flavors.

What I have tried, but did not work:

  • I added exactly the same flavors that base module (my-app) has in my dynamic module
  • In build.gradle of my DFM, I tried to set configuration explicitly like : implementation project(path: ':my-app', configuration: 'default') and also configuration: 'someFlavor'
  • In build.gradle of the base module (my-app) I used missingDimensionStrategy 'mydimension', 'myflavor'
  • Building from Android Studio and also from terminal
  • Removing dependencies and other code from build.gradle files

What I have tried and it worked:

  • Removing the dependency of base app (my-app) from DFM (i.e. removing implementation project(':my-app',) ) - but I need it. Just to clarify, the DFM applies the following gradle plugins: com.android.dynamic-feature and kotlin-android
  • Removing all flavors from the base app and DFM - but I need them in the base app.
  • The PoC I made works fine and gradle compiles the project even with the same flavors I use in my actual project

Notes:

  • I use DexGuard (but I disabled it to make sure it isn't interfering)
  • I don't have any custom build types, only 'debug' and 'release'
  • Gradle version is 3.5.2
  • Gradle wrapper is 5.5.1
  • Both the PoC and my actual project use the same versions of gradle, gradle wrapper, build types and flavors

Unfortunately I could not reproduce the problem in a separate project. I tried removing as much of things as possible from my project but I could not resolve the issue.

Do you have any idea what could be causing this issue and how could I possibly fix it? Thank you!

like image 344
mrmitew Avatar asked Dec 02 '19 08:12

mrmitew


1 Answers

I had this issue and it was due to not removing the implementation project(':features:myDynamicFeatureModule') line from my app module's gradle file.

like image 181
Sha Sha Avatar answered Oct 19 '22 07:10

Sha Sha