当前位置: 首页 > 知识库问答 >
问题:

为什么没有检测到JAVA版本?Android Gradle插件需要Java 11才能运行。您当前正在使用Java1.8

怀刚毅
2023-03-14

我正在尝试在app Center中构建应用程序。建筑格拉德尔

buildscript {
    ext.kotlin_version = "1.5.30"
    repositories {
        google()
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.bugsnag:bugsnag-android-gradle-plugin:7.0.0"
    }
}

应用程序构建。格拉德尔

apply plugin: "com.android.application"
apply plugin: "kotlin-android"

android {
    compileSdkVersion 30
    ndkVersion "17.2.4988734"

    defaultConfig {
        applicationId "com.example.bugsnag.android"
        minSdkVersion 14
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
    }
    signingConfigs {
        config {
            keyAlias "password"
            keyPassword "password"
            storeFile file("../fakekeys.jks")
            storePassword "password"
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.config
        }
    }
    externalNativeBuild.cmake.path "CMakeLists.txt"
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = "11"
    }
}

dependencies {
    implementation "com.bugsnag:bugsnag-android:5.12.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation "androidx.appcompat:appcompat:1.3.1"
    implementation "com.google.android.material:material:1.4.0"
}

apply plugin: "com.bugsnag.android.gradle"
bugsnag.failOnUploadError = false

为什么没有检测到Java11?如何测试这个?

应用程序中心生成日志

> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
     You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.

如何编辑gradle.properties?org.gradle.java.home=什么?

如果解决了JDK 11,为什么构建失败?

共有1个答案

班高明
2023-03-14

针对您的问题有两种解决方案

>

将JDK 11 path放入您的PATH环境变量中,并从中删除所有其他JDK。

 类似资料: