# Error implementing multiplatform library dependency in Android project

**URL:** <https://discuss.kotlinlang.org/t/error-implementing-multiplatform-library-dependency-in-android-project/20607>\
**Category:** Multiplatform\
**Created:** [January 20, 2021, 12:33pm UTC](https://discuss.kotlinlang.org/t/error-implementing-multiplatform-library-dependency-in-android-project/20607 "2021-01-20T12:33:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SuffiX](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@SuffiX](https://discuss.kotlinlang.org/u/SuffiX)\
**Post date:** [January 20, 2021, 12:33pm UTC](https://discuss.kotlinlang.org/t/error-implementing-multiplatform-library-dependency-in-android-project/20607/1 "2021-01-20T12:33:33Z")

</div>

Hello, community!

I have created Kotlin Multiplatform library “c4view-worldwind” with Android, JVM and JS targets.  
I have successfully publish this library into maven local repository. I can see all classes, resources, manifest and meta info inside local repository “~/.m2/…” folder.  
I have successfully added dependency to my library in my Android application using following code:  
`implementation ('vision.combat:c4view-worldwind-android:1.0-SNAPSHOT@aar') {transitive=true}`

But when I try to build project, I receive following error:  
Execution failed for task ‘:c4map:dataBindingMergeDependencyArtifactsDebug’.  
\> Could not resolve all files for configuration ‘:c4map:debugCompileClasspath’.  
\> Could not resolve vision.combat:c4view-worldwind-android:1.0-SNAPSHOT.  
Required by:  
project :c4map  
\> No matching variant of vision.combat:c4view-worldwind-android:1.0-SNAPSHOT was found. The consumer was configured to find an API of a component, as well as attribute ‘com.android.build.api.attributes.BuildTypeAttr’ with value ‘debug’ but:  
- Variant ‘commonMainMetadataElements-published’ capability vision.combat:c4view-worldwind-android:1.0-SNAPSHOT:  
- Incompatible because this component declares a usage of ‘kotlin-api’ of a component and the consumer needed an API of a component  
- Other compatible attribute:  
- Doesn’t say anything about com.android.build.api.attributes.BuildTypeAttr (required ‘debug’)  
- Variant ‘metadataApiElements-published’ capability vision.combat:c4view-worldwind-android:1.0-SNAPSHOT:  
- Incompatible because this component declares a usage of ‘kotlin-metadata’ of a component and the consumer needed an API of a component  
- Other compatible attribute:  
- Doesn’t say anything about com.android.build.api.attributes.BuildTypeAttr (required ‘debug’)  
- Variant ‘releaseApiElements-published’ capability vision.combat:c4view-worldwind-android:1.0-SNAPSHOT declares an API of a component:  
- Incompatible because this component declares a component, as well as attribute ‘com.android.build.api.attributes.BuildTypeAttr’ with value ‘release’ and the consumer needed a component, as well as attribute ‘com.android.build.api.attributes.BuildTypeAttr’ with value ‘debug’  
- Variant ‘releaseRuntimeElements-published’ capability vision.combat:c4view-worldwind-android:1.0-SNAPSHOT declares a runtime of a component:  
- Incompatible because this component declares a component, as well as attribute ‘com.android.build.api.attributes.BuildTypeAttr’ with value ‘release’ and the consumer needed a component, as well as attribute ‘com.android.build.api.attributes.BuildTypeAttr’ with value ‘debug’

How to fix this issue?

---

<div class="post-metadata">

**Author:** ![SuffiX](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@SuffiX](https://discuss.kotlinlang.org/u/SuffiX)\
**Post date:** [January 20, 2021, 12:55pm UTC](https://discuss.kotlinlang.org/t/error-implementing-multiplatform-library-dependency-in-android-project/20607/2 "2021-01-20T12:55:23Z")

</div>

Similar issue [Publish library that uses apollo-android internally · Issue #2401 · apollographql/apollo-kotlin · GitHub](https://github.com/apollographql/apollo-android/issues/2401)

---

<div class="post-metadata">

**Author:** ![SuffiX](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@SuffiX](https://discuss.kotlinlang.org/u/SuffiX)\
**Post date:** [January 20, 2021, 1:20pm UTC](https://discuss.kotlinlang.org/t/error-implementing-multiplatform-library-dependency-in-android-project/20607/3 "2021-01-20T13:20:44Z")

</div>

There is no error in case I implement dependency like this, but it selects JVM library instead of Android:  
`implementation 'vision.combat:c4view-worldwind:1.0-SNAPSHOT'`

---

<div class="post-metadata">

**Author:** ![SuffiX](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@SuffiX](https://discuss.kotlinlang.org/u/SuffiX)\
**Post date:** [January 20, 2021, 1:44pm UTC](https://discuss.kotlinlang.org/t/error-implementing-multiplatform-library-dependency-in-android-project/20607/4 "2021-01-20T13:44:42Z")

</div>

Fixed by adding in library:

> ```
> kotlin {
> android {
> publishAllLibraryVariants()
> publishLibraryVariantsGroupedByFlavor = true // This line
> }
> }
> 
> ```
