在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中添加邮箱和持卡人姓名?


当前回答

首先,进入设置,然后导航到插件。找到Kotlin插件并更新它。

接下来,在gradle文件中,去构建。gradle(项目:YourApp)。然后,更改以下代码(在buildscript中):

ext.kotlin_version = '1.3.50'

到最新版本,如:

ext.kotlin_version = '1.4.32'

要了解最新版本,请转到设置和插件,找到Kotlin插件,并确保它已更新。最新版本是在JetBrains名下。

按照说明操作后,您的错误将得到解决。

其他回答

另一个解决方案是降级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。

我在Flutter中遇到了同样的问题,我通过转到: 文件>设置>插件@Muzzamil说,我检查了我的IDE中的Kotlin版本,并简单地将ext.kotlin_version(即1.6.10)中的值替换为该值

ext.kotlin_version = '1.6.10'

使用Flutter,由以下方法修复:

更新Android Studio包,特别是Kotlin插件。 从Gradle - plugin和versions中获取Kotlin插件的最新版本Nbr。目前是1.6.10。 安卓系统更新< Your_project_name_folder > \ \构建。gradle文件替换旧的Kotlin版本的新一个你从上面的网站。 ext.kotlin_version = '<The_new_version_Nbr>'在我的例子中ext.kotlin_version = '1.6.10' 重新启动Visual Studio代码。

你就完成了。

我在Flutter项目中遇到过这个问题。

在我的例子中,Android版本中缺少kotlin-gradle-plugin的一行。所以添加ext.kotlin_version = '1.6.10'并不能修复它。

后添加

classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version”

错误消失了。

完整代码部分:

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

例如:

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