配置 kotlin-gradle-plugin、kotlin-android 和 kotlin-android-extensions 后,React native android 构建失败
React native android build is failing after configured kotlin-gradle-plugin, kotlin-android and kotlin-android-extensions
我在我的 React Native 项目中实现了 AWS chime。如前所述 here 我必须将以下配置添加到我的项目中。
build.gradle
文件更改
buildscript {
ext.kotlin_version = '1.3.71'
...
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
app/build.gradle
文件更改
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
implementation 'androidx.core:core-ktx:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
当我配置这些更改并在 yarn android
(构建)之后,我的构建失败并在 node_modules
.
中出现 .kt
文件错误
e: /projects/rndemo/node_modules/expo/android/src/main/java/expo/modules/ExpoModulesPackage.kt: (27, 9): Type inference failed: Not enough information to infer parameter T in fun <T> emptyList(): List<T>
Please specify it explicitly.
e: /projects/rndemo/node_modules/expo/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt: (48, 12): Type inference failed: fun <T, A> invokeDelegateMethod(name: String, argTypes: Array<Class<*>>, args: Array<A>): T
cannot be applied to
(String,Array<Class<*>>,Array<String?>)
没有上述配置更改应用程序工作正常。
这是什么原因?
有没有办法跳过使用指定的 kotlin 版本编译的节点模块?
通过更新 kotlin 版本解决了问题,即 ext.kotlin_version = '1.5.31'
我在我的 React Native 项目中实现了 AWS chime。如前所述 here 我必须将以下配置添加到我的项目中。
build.gradle
文件更改
buildscript {
ext.kotlin_version = '1.3.71'
...
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
app/build.gradle
文件更改
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
implementation 'androidx.core:core-ktx:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
当我配置这些更改并在 yarn android
(构建)之后,我的构建失败并在 node_modules
.
.kt
文件错误
e: /projects/rndemo/node_modules/expo/android/src/main/java/expo/modules/ExpoModulesPackage.kt: (27, 9): Type inference failed: Not enough information to infer parameter T in fun <T> emptyList(): List<T>
Please specify it explicitly.
e: /projects/rndemo/node_modules/expo/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt: (48, 12): Type inference failed: fun <T, A> invokeDelegateMethod(name: String, argTypes: Array<Class<*>>, args: Array<A>): T
cannot be applied to
(String,Array<Class<*>>,Array<String?>)
没有上述配置更改应用程序工作正常。
这是什么原因?
有没有办法跳过使用指定的 kotlin 版本编译的节点模块?
通过更新 kotlin 版本解决了问题,即 ext.kotlin_version = '1.5.31'