繁体   English   中英

任务:react-native-webview:compileDebugJavaWithJavac 失败

[英]Task :react-native-webview:compileDebugJavaWithJavac FAILED

当我在安装 react-native.webview package 后尝试运行我的 React Native 应用程序时,我一直收到此错误。请问我做错了什么。

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1135 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details

> Task :react-native-webview:compileDebugJavaWithJavac

> Task :react-native-webview:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
79 actionable tasks: 14 executed, 65 up-to-date
C:\Projects\React-Native\FUNAI\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewModule.java:276: error: cannot find symbol
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                                                    ^
  symbol:   variable Q
  location: class VERSION_CODES
Note: C:\Projects\React-Native\FUNAI\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Projects\React-Native\FUNAI\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-webview:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 37s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\Projects\React-Native\FUNAI\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewModule.java:276: error: cannot find symbol
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                                                    ^
  symbol:   variable Q
  location: class VERSION_CODES
Note: C:\Projects\React-Native\FUNAI\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Projects\React-Native\FUNAI\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-webview:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 37s

    at makeError (C:\Projects\React-Native\FUNAI\node_modules\execa\index.js:174:9)
    at Promise.all.then.arr (C:\Projects\React-Native\FUNAI\node_modules\execa\index.js:278:16)
    at process._tickCallback (internal/process/next_tick.js:68:7)

当我安装 WebView 时,我也遇到了同样的问题。

要修复它,您需要将您的compileSdkVersion更新为 29。当您使用它时,您不妨更新buildToolsVersion 您可以通过在项目的/android/build.gradle文件中更改这些行来做到这一点。

buildscript {
    ext {
        …
        buildToolsVersion = "29.0.3"
        compileSdkVersion = 29
        …
    }
…
}

无需更改您的“compileSdkVersion”和“buildToolsVersion”。 只需安装 WebView 版本 12.1.0,就是这样! 为我工作!

首先使用以下命令卸载任何以前的版本:

npm uninstall react-native-webview

现在安装 12.1.0 版本:

npm install react-native-webview@12.1.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM