当我想将 "react-native-webview": "^11.22.4"
与 "react-native-video": "^5.2.0 一起使用时,我遇到了这个问题“
。当我想使用React Native Video时出现问题
D:\Document\Nodejs\Github\trender\mobile-interface\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\events\TopShouldStartLoadWithRequestEvent.kt: (28, 21):
Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from C:/Users/Alex/.gradle/caches/transforms-3/dd0d00050014aa294dc6be948e80b5b3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
这是我的 build.gradle
文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
kotlin_version = '1.1.15'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath ('com.google.gms:google-services:4.3.3')
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
maven { url 'https://www.jitpack.io' }
jcenter() {
content {
includeModule("com.yqritc", "android-scalablevideoview")
}
}
}
}
最佳答案
在 android/build.gradle 中添加 kotlinVersion = "1.6.0"
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
kotlinVersion = "1.6.0"
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:4.1.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
关于android - 类 'kotlin.Unit' 是使用不兼容的 Kotlin 版本编译的。其元数据的二进制版本是1.6.0,预期版本是1.1.15,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72839008/