无法解析依赖项.没有匹配的变体



我在Android项目中得到了由以下依赖项引起的构建错误:
implementation "com.algolia:instantsearch-android:2.5.1"
它有助于升级到2.8.0,但我宁愿不,因为它需要minSdk 21

Gradle 6.5
Android Gradle Plugin: 4.0.2
Kotlin 1.3.72

Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:releaseCompileClasspath'.
> Could not resolve com.algolia:algoliasearch-client-kotlin-common:1.4.0.
Required by:
project :app > com.algolia:instantsearch-android:2.5.1
> No matching variant of com.algolia:algoliasearch-client-kotlin-common:1.4.0 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 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
- Variant 'metadata-api' capability com.algolia:algoliasearch-client-kotlin-common:1.4.0:
- Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'release')

我也有类似的情况,但我的情况与您的略有不同。我将解释我的情况和你的情况之间的区别,以及我是如何纠正这种情况的。这可能是你的问题的线索,但我要让你看看它是否适用或有用。

在我的例子中,关于不兼容的错误说消费者有一个属性'org.jetbrains.kotlin.platform。输入'与值'androidJvm',它发现我的依赖有一个属性'org.jetbrains.kotlin.platform。输入',值'jvm'。请注意,我没有确切的文本和消息讨论其他属性和组件。但是当我解析消息时,明显的区别是'androidJvm'和'jvm'。

我做错的是,我试图将android库依赖项添加到java库中,当然,这是不允许的。我已经将"java-library"插件应用于依赖项,而不是应用"com.android"。插件'到该库。当我离开时,我纠正了这个问题。

在你的情况下,看起来你有不同的'common'与'androidJvm'。不幸的是,我不知道"普通"平台类型指的是什么。这可能是由于你所应用的插件类型。希望这对你有所帮助!

最新更新