React Native Webview错误: 无法创建任务 ‘:react-native-webview:compileDebugAndroidTestKotlin’

huangapple go评论61阅读模式
英文:

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

问题

我正在尝试使用React Native创建一个Webview应用程序。当我尝试为Android构建时,我遇到了以下错误。

我在互联网上找不到解决方法。此外,我在Github问题中也找不到任何答案。你能帮助我吗?

错误信息如下:

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

我正在使用MacOS Ventura 13.4.1,配备了M1 Apple Silicon。

build.gradle 文件:

// 顶级 build 文件,您可以在其中添加所有子项目/模块的通用配置选项。

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

        // 我们使用的 NDK 版本是 23,它既支持 M1,也是 AGP 的并行 NDK 版本。
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
    }
}

这是我的 JDK 信息:

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"
  }
}
英文:

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"
  }
}

答案1

得分: 0

我通过安装较低版本的React Native项目解决了我的问题。

react-native init MyApp --version 0.71.8

然后我安装了较低版本的react-native webview包。

npm i react-native-webview@12.0.2
英文:

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

huangapple
  • 本文由 发表于 2023年7月20日 20:28:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76729876.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定