reactnativecn / react-native-website

React Native 中文网
https://reactnative.cn
MIT License
216 stars 327 forks source link

我在尝试引入react-native-webview时出现错误:Execution failed for task ':react-native-webview:compileDebugKotlin' #610

Closed Komorebi-Nine closed 2 years ago

Komorebi-Nine commented 2 years ago

请按以下格式提供问题的相关信息。

环境

  1. nodejs => 16.0.0
  2. jdk => 12
  3. ndk => 20.1.5948944
  4. react => 18.0.0
  5. react-native => 0.69.0
  6. react-native-webview => ^11.22.4
  7. react-native-cli => 7.0.3

问题的具体描述

根据官方文档,我在上述环境中使用命令 npx react-native init AwesomeTSProject --template react-native-template-typescript 来构建 React-Native 项目后,使用 yarn android 成功打包并且运行我的代码

但是当我尝试引入 react-native-webview 时,运行 yarn android 打包后抛出如下错误: Execution failed for task ':react-native-webview:compileDebugKotlin'

尝试使用 gradlew.bat assembleRelease 命令后,抛出错误: Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

尝试使用 gradlew.bat greendao --warning-mode all --stacktrace 抛出错误: Task 'greendao' not found in root project 'WebView'

在当前版本下,无论是 js 还是 ts,在创建项目起初都能够正常运行并且打包,但是当我尝试引入 webview 组件的时候就会出现如上错误,在旧版本里:

  1. react => 17.0.1
  2. sdk => 12
  3. ndk => 20.1.5948944
  4. react => 17.0.1
  5. react-native => 0.64.1
  6. react-native-webview => ^11.6.2
  7. gradle-wrappers gradle => 6.7
  8. build.gradle gradle => 4.1.0 项目能够正常运行。 当我尝试使用旧项目中的 gradle 版本时,依然无法正常工作。

请问有遇到类似情况的开发者吗,我需要帮助。

Komorebi-Nine commented 2 years ago

我认为问题出在 gradle 与 webview 之间,是否有相关的文档说明过这两者之间的兼容性问题呢?

Komorebi-Nine commented 2 years ago

经过多个项目构建,应该是 webview 还没有对新版本的 react-native 提供支持, 测试发现0.68.0能够正常编译 webview,0.69.0版本不能够正常编译

sunnylqm commented 2 years ago

这个应该去 react-native-webview 的仓库中提问

Komorebi-Nine commented 2 years ago

这个应该去 react-native-webview 的仓库中提问

您说得对,在忙完这一阶段的事情之后我会去它们的仓库提一个issue,抱歉打扰到你们了,我已经关闭了该 issue,事实上也可能有人有类似的困境,希望能够帮助到别人。