androidreactjsreact-nativereact-native-webview

React Native Webview Error: Could not create task ':react-native-webview:compileDebugAndroidTestKotlin'


I am trying to create a Webview application with React Native. When I try to build it for Android, I encounter the following error.

I couldn't find a solution for this on the internet. Moreover, I couldn't find any answers in the Github issues either. Can you help me?

ERROR

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':tasks'.
Could not create task ':react-native-webview:compileDebugAndroidTestKotlin'.
No enum constant org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.JvmTargetValidationMode.WARNİNG

I am using MacOS Ventura 13.4.1 with M1 Apple Silicon

build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 34


        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")

    }
}

This is my JDK info:

openjdk 11.0.20 2023-07-18 LTS
OpenJDK Runtime Environment Zulu11.66+15-CA (build 11.0.20+8-LTS)
OpenJDK 64-Bit Server VM Zulu11.66+15-CA (build 11.0.20+8-LTS, mixed mode)

package.json:

{
  "name": "MyApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "react": "18.2.0",
    "react-native": "0.72.3",
    "react-native-fs": "^2.20.0",
    "react-native-share": "^9.2.3",
    "react-native-webview": "^13.2.3",
    "rn-fetch-blob": "^0.12.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/eslint-config": "^0.72.2",
    "@react-native/metro-config": "^0.72.9",
    "@tsconfig/react-native": "^3.0.0",
    "@types/react": "^18.0.24",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.76.7",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0",
    "typescript": "4.8.4"
  },
  "engines": {
    "node": ">=16"
  }
}

Solution

  • I solved my problem by installing react native project with lower version.

    react-native init MyApp --version 0.71.8
    

    And then I installed react-native webview package with lower version.

    npm i react-native-webview@12.0.2