【问题标题】:React Native - Make sure Gradle is running on a JDK, not JREReact Native - 确保 Gradle 在 JDK 而不是 JRE 上运行
【发布时间】:2021-12-26 22:39:18
【问题描述】:

我在Expo 有一个应用程序并使用了expo eject

我的应用在 iOS 上运行良好,使用 npx react-native run-ios

在 Android 上运行时遇到问题,出现以下问题:

> Task :unimodules-core:compileDebugKotlin 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.1.1/userguide/command_line_interface.html#sec:command_line_warnings
362 actionable tasks: 5 executed, 357 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':unimodules-core:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home' used by Gradle. Make sure Gradle is running on a JDK, not JRE.

在目录/Library/Internet Plug-Ins 我有:

这是我的 bash_profile:

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

export JAVA_HOME=/Applications/"Android Studio.app"/Contents/jre/jdk/Contents/Home

这是我的build.gradle 文件:

buildscript {
ext {
    buildToolsVersion = "30.0.0"
    minSdkVersion = 21
    compileSdkVersion = 30
    targetSdkVersion = 30
}
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.google.gms:google-services:4.3.3'
    classpath("com.android.tools.build:gradle:4.0.1")

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    mavenLocal()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url("$rootDir/../node_modules/react-native/android")
    }
    maven {
        // Android JSC is installed from npm
        url("$rootDir/../node_modules/jsc-android/dist")
    }

    google()
    jcenter()
    maven { url 'https://www.jitpack.io' }
}
}

我的gradle-wrapper.properties 文件:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

尝试了各种 stackoverflow 帖子,但似乎无法解决此问题,非常感谢任何帮助。

【问题讨论】:

  • 我也开始遇到这个问题

标签: java android react-native kotlin expo


【解决方案1】:

问题似乎出在 JDK 上。您是否在系统中安装了 JDK? 尝试使用 v8 下载 JDK,然后重试。它应该运行。如果安装了其他版本,请尝试安装特定于 8 的版本。

你可以从这里找到官方包-

https://www.oracle.com/in/java/technologies/javase/javase8-archive-downloads.html

【讨论】:

猜你喜欢
  • 2019-06-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-26
  • 2014-01-17
  • 1970-01-01
  • 2016-04-29
  • 2013-11-08
相关资源
最近更新 更多