【问题标题】:React native android build is failing after configured kotlin-gradle-plugin, kotlin-android and kotlin-android-extensions配置 kotlin-gradle-plugin、kotlin-android 和 kotlin-android-extensions 后,React Native android 构建失败
【发布时间】:2021-12-22 12:12:30
【问题描述】:

我在我的 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(构建)之后,我的构建失败,.kt 文件错误出现在node_modules

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 版本编译的节点模块?

【问题讨论】:

    标签: android react-native kotlin expo


    【解决方案1】:

    通过将 kotlin 版本更新为 ext.kotlin_version = '1.5.31' 解决了该问题

    【讨论】:

      猜你喜欢
      • 2017-12-16
      • 2021-03-18
      • 2020-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-18
      • 2018-02-07
      相关资源
      最近更新 更多