在Stripe中,我的客户需要电子邮件和持卡人的姓名,但Stripe支付UI没有在com.stripe.android.view.CardMultilineWidget中提供该选项。我想试试最新的条纹版,

I was using Stripe version (14.1.1). So I updated it to the latest one (16.8.0) The build showed me the error that it doesn't take minSdkVersion 19. It requires 21 in manifest merger. So I updated minSdkVersion to 21. I got caches/transforms-2/files-2.1/4541b0189187e0017d23bbb0afebd16a/jetified-kotlin-stdlib-common-1.5.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

我尝试改变Gradle版本,但我仍然得到相同的错误。如何解决不兼容的错误,在Stripe中添加邮箱和持卡人姓名?


当前回答

另一个解决方案是降级androidx。Core: Core -ktx库到任何兼容版本。这个代码适用于kotlin_version = '1.3.31':

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.3.1'  // The only working for this version (sdk/gradle)
    implementation 'androidx.core:core-ktx:1.0.2' // The only working for this version (sdk/gradle)
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2' // higher versions require min-sdk >= 26
    ...
}

Android SDK: compileSdkVersion 30和minSdkVersion 19。

Gradle构建工具:com.android.tools.build: Gradle:3.3.1。

其他回答

我已经设置了minsdk 24并重新启动Android Studio,其工作正常。

确保你的IDE的Kotlin版本与你在gradle中声明的版本相同。构建文件。

虽然这个问题已经得到了回答,但我认为有必要解释一下正在发生的事情

例如:

The binary version of its metadata is 1.7.1, expected version is 1.5.1.

预期的版本是Kotlin for Kotlin -gradle-plugin

二进制版本是下载的(或之前编译的) com.android.tools.build: gradle

< project_dir > - android gradle构建。

buildscript {
    ext.kotlin_version = '1.5.20' // <= expected version is 1.5.1
}
dependencies {
    classpath 'com.android.tools.build:gradle:7.3.1' // downloads 1.7.1 Metadata
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // <= 1.5.20 used here

为什么这种情况如此普遍?

用户根据警告更新插件的Kotlin版本以匹配IDE版本。

用户根据警告更新android构建工具gradle插件

这是错误的版本!

现在你没有任何警告,但建议的版本是7.1.3,这不是最新的。(我不知道为什么它建议这个旧版本)7.3.1是目前最新的,是元数据1.7.1,所以它将匹配Kotlin版本的1.7.20(也是元数据1.7.1)

还有什么错呢?

由于缓存,gradle可能在你更新之前使用了一个旧的依赖项。清洁开始:

删除~/.gradle /缓存目录 删除“android/.”gradle目录 删除project_dir/build目录 确保android/gradle/gradle-wrapper。property有正确的distributionUrl(当前distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip) 从project_dir做颤振构建apk

注意:你的依赖可能需要更新如果他们的com.android.tools。Build:gradle版本太旧。或者,kotlin和tools:gradle版本都可以降级为匹配元数据的兼容版本(尽管Android Studio会警告不匹配IDE kotlin版本)

如何防止这种情况再次发生?

对于ext.kotlin_version,通常使用与IDE相同的Kotlin版本。看到https://kotlinlang.org/docs/releases.html版本细节 仔细检查com.android.tools。构建:gradle版本。参见https://developer.android.com/studio/releases/gradle-plugin#updating-gradle和https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google

在文件构建中更改此。Gradle解决了我的问题。

From

ext.kotlin_version = '1.3.50'

to

ext.kotlin_version = '1.6.0'

或者任何最新版本的Kotlin可用,并确保在Android Studio上更新Kotlin版本。

在我的案例中

其元数据的二进制版本为1.7.1,预期版本为1.5.1

得到build.gradle(project)中的(dependencies)从1.5转换。X (X)在这里是(20)

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"

对1.7.10

 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"