简体   繁体   中英

React Native - Make sure Gradle is running on a JDK, not JRE

I had an app in Expo and used expo eject .

My app runs fine on iOS using npx react-native run-ios

Running on Android im having problems, getting the following issue:

> 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.

In the Directory /Library/Internet Plug-Ins I have:

在此处输入图片说明

And this is my 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

Here is my build.gradle file:

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

my gradle-wrapper.properties file:

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

Tried various stackoverflow posts but Cant seem to fix this issue, any help is much appreciated.

The problem seems to be with JDK. Have you installed JDK in your system? Try downloading JDK with v8 and try again. It should run. Try installing particular to 8 if any other is installed.

You can find officiel package from here-

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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