Ant*_*ony 6 android gradle kotlin react-native kotlin-experimental
我一直在尝试构建 React Native 应用程序,我一直在到处搜索,但无法解决这个问题。任何帮助或建议都将非常感激。
我的 Android 版本出现此错误:
/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt: (137, 11): This declaration is experimental and its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'
Run Code Online (Sandbox Code Playgroud)
在react-native-gradle-plugin中,我找到了文件BundleHermesCTask.kt。在此文件中,它向我显示此函数的错误,我可以将此行放在函数 @OptIn(ExperimentalStdlibApi::class) 之上,程序将构建并工作,但更改节点模块不是解决方案,因为它将被覆盖。
internal fun getBundleCommand(bundleFile: File, sourceMapFile: File): List<Any> =
windowsAwareCommandLine(
buildList {
addAll(nodeExecutableAndArgs.get())
add(cliFile.get().asFile.absolutePath)
add(bundleCommand.get())
add("--platform")
add("android")
add("--dev")
add(devEnabled.get().toString())
add("--reset-cache")
add("--entry-file")
add(entryFile.get().asFile.toString())
add("--bundle-output")
add(bundleFile.toString())
add("--assets-dest")
add(resourcesDir.get().asFile.toString())
add("--sourcemap-output")
add(sourceMapFile.toString())
if (bundleConfig.isPresent) {
add("--config")
add(bundleConfig.get().asFile.absolutePath)
}
add("--minify")
add(minifyEnabled.get().toString())
addAll(extraPackagerArgs.get())
add("--verbose")
})
Run Code Online (Sandbox Code Playgroud)
我在网上搜索并尝试了所有方法,从检查我的java版本到检查所有依赖项是否加载相同版本以及更新反应本机和依赖项。我唯一能做的就是更改文件 BundleHermesCTask.kt,但我无法执行此操作,因为构建过程将移动应用程序并执行 npm 安装所有依赖项,并且更改会丢失。
我已经检查了 github 页面,也一直在尝试了解 kotlin 有关 kotlin 的更多信息,并阅读
https://kotlinlang.org/docs/opt-in-requirements上的文档
| 归档时间: |
|
| 查看次数: |
3859 次 |
| 最近记录: |