react-native-webview: Task :react-native-webview:compileDebugJavaWithJavac FAILED
import React, { Component } from 'react';
import { View } from 'react-native';
import { WebView } from 'react-native-webview';
export default class App extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<WebView source={{ uri: 'https://www.baidu.com' }} />
</View>
);
}
}
yarn add react-native-webview
yarn android
have a problem
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 16 actionable tasks: 16 executed E:\react-native-pro\test\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewModule.java:276: � ���: �Ҳ������� if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { ^ ����: ���� Q λ��: �� VERSION_CODES ע: E:\react-native-pro\test\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.javaʹ� û�����ѹ�ʱ�� API�� ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣 ע: E:\react-native-pro\test\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.javaʹ� ���δ�������ȫ�IJ����� ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣 1 ������
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 34s
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 E:\react-native-pro\test\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewModule.java:276: � ���: �Ҳ������� if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { ^ ����: ���� Q λ��: �� VERSION_CODES ע: E:\react-native-pro\test\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.javaʹ� û�����ѹ�ʱ�� API�� ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣 ע: E:\react-native-pro\test\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.javaʹ� ���δ�������ȫ�IJ����� ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣 1 ������
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 34s
at makeError (E:\react-native-pro\test\node_modules\execa\index.js:174:9)
at E:\react-native-pro\test\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (E:\react-native-pro\test\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (E:\react-native-pro\test\node_modules\@react-native-community\cli\build\index.js:186:9)
error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 15
- Comments: 23
@vervin I have a solution.
build.gradle
file in theandroid
folder (${workspace}/android/build.gradle).compileSdkVersion
to 29 in thebuildscript > ext
section.In my case, I installed react-native-webview 11.4.6 in my android/build.gradle I have the following: buildToolsVersion = “30.0.0” minSdkVersion = 21 compileSdkVersion = 30 targetSdkVersion = 30 ndkVersion = “23.0.7272597”
my complieSdkVersion and targetSdkVersion are 30 because expo-permission requires it to be 30, but all the solution am seeing for the react-native-webview is to make complieSdkVersion and targetSdkVersion to 29. How do I solve my issue? Any help is appreciated.
I had to update the targetSdkVersion and compileSdkVersion to 33 in my project to give support to Android 13 devices. Webview threw the same error, when i tried to build the app and in my case it was fixed when react-native-webview was upgraded to version “11.22.7”.
Bumping compileSdkVersion to 29 does not help me, still get the
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
problem. Triedgradlew clean
in the Android folder too, to no avail. I have SDK 29 installed.Hey @wiredmatrix , I was able to fix this. The version in package.json and package-lock.json was mismatching. I uninstalled the old package and reinstalled it again to get it fixed. I hope this should fix your issue as well.
Upgrading to v10.4.0 fixed this issue for me.
works!! thanks!
This solution works!!