Код: Выделить всё
The supplied phased action failed with an exception.
Could not create task ':vibration:compileDebugJavaWithJavac'.
Failed to calculate the value of task ':vibration:compileDebugJavaWithJavac' property 'javaCompiler'.
Toolchain installation '/usr/lib/jvm/java-21-openjdk-amd64' does not provide the required capabilities: [JAVA_COMPILER]
< /code>
Во -первых, я не знаю, что означает эта ошибка. Я просто знаю, что Gradle нуждается в Javacompiler Код: Выделить всё
$ echo $JAVA_HOME
/usr/lib/jvm/java-17-openjdk-amd64
< /code>
$ java -version
openjdk version "17.0.15" 2025-04-15
OpenJDK Runtime Environment (build 17.0.15+6-Ubuntu-0ubuntu124.04)
OpenJDK 64-Bit Server VM (build 17.0.15+6-Ubuntu-0ubuntu124.04, mixed mode, sharing)
< /code>
I previously had JDK 21 installed but shifted to JDK 17 without deleting JDK 21.
The app builds perfectly fine, and runs smoothly. But according to ChatGPT, I have to resolve this issue before releasing to Google Play Store as it might cause build issue for future releases.
This is my android/build.gradle,ktsКод: Выделить всё
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.google.gms:google-services:4.4.2") // or latest stable
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register("clean") {
delete(rootProject.layout.buildDirectory)
}
< /code>
And my android/app/build.gradle.ktsimport java.util.Properties
plugins {
id("com.android.application")
id("com.google.gms.google-services")
id("kotlin-android")
id("dev.flutter.flutter-gradle-plugin")
}
val keystoreProperties = Properties().apply {
val keystorePropertiesFile = rootProject.file("key.properties")
if (keystorePropertiesFile.exists()) {
keystorePropertiesFile.inputStream().use { load(it) }
} else {
throw GradleException("Missing key.properties file in android/ directory")
}
}
android {
namespace = "com.example.progresspal"
compileSdk = flutter.compileSdkVersion
ndkVersion = "27.0.12077973"
signingConfigs {
create("release") {
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
}
}
defaultConfig {
applicationId = "com.example.progresspal"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
getByName("release") {
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
}
flutter {
source = "../.."
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
}import java.util.Properties
plugins {
id("com.android.application")
id("com.google.gms.google-services")
id("kotlin-android")
id("dev.flutter.flutter-gradle-plugin")
}
val keystoreProperties = Properties().apply {
val keystorePropertiesFile = rootProject.file("key.properties")
if (keystorePropertiesFile.exists()) {
keystorePropertiesFile.inputStream().use { load(it) }
} else {
throw GradleException("Missing key.properties file in android/ directory")
}
}
android {
namespace = "com.example.progresspal"
compileSdk = flutter.compileSdkVersion
ndkVersion = "27.0.12077973"
signingConfigs {
create("release") {
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
}
}
defaultConfig {
applicationId = "com.example.progresspal"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
getByName("release") {
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
}
flutter {
source = "../.."
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
}
< /code>
I tried asking ChatGPT for a solution, changed a bunch of stuff, installed JDK 17 and set it as default. But Gradle is not picking up JDK 17 due to some reason.
Подробнее здесь: https://stackoverflow.com/questions/796 ... adle-issue
Мобильная версия