Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=17...
I'm not entirely sure what happened, but I recently updated to the latest Skip version and started getting the following error when trying to compile my project in Xcode.
* What went wrong:
Could not determine the dependencies of task ':app:packageDebug'.
> Could not create task ':app:compileDebugJavaWithJavac'.
> Failed to calculate the value of task ':app:compileDebugJavaWithJavac' property 'javaCompiler'.
> Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=17, vendor=any, implementation=vendor-specific} for MAC_OS on aarch64.
> No locally installed toolchains match and toolchain download repositories have not been configured.
It's not clear to me why it's referencing languageVersion=17. I have the following installed:
jeff@M3-MBP Android % java --version
openjdk 21.0.3 2024-04-16
OpenJDK Runtime Environment Homebrew (build 21.0.3)
OpenJDK 64-Bit Server VM Homebrew (build 21.0.3, mixed mode, sharing)
jeff@M3-MBP Android % echo $JAVA_HOME
/opt/homebrew/Cellar/openjdk@21/21.0.3
Skip checkup seems to work properly:
[✓] Skip version 0.8.55 (= 0.8.55)
[✓] macOS version 14.5 (> 13.5.0)
[✓] Swift version 5.10 (> 5.9.0)
[✓] Xcode version 15.4 (> 15.0.0)
[✓] Xcode tools SDKs: 9
[✓] Homebrew version 4.3.7 (> 4.1.0)
[✓] Gradle version 8.8 (> 8.6.0)
[✓] Java version 21.0.3 (> 21.0.0)
[✓] Android Debug Bridge version 1.0.41 (> 1.0.40)
[✓] Android Studio version: 2023.3
[✓] Android tools SDKs: 4
[✓] Resolve dependencies (6.53s)
[✓] Build hello-skip (7.16s)
[✓] Test Swift (4.58s)
[✓] Test Kotlin (27.85s)
[✓] Archive iOS ipa (12.12s)
[✓] Assemble HelloSkip-release.ipa 37 KB
[✓] Verify HelloSkip-release.ipa 37 KB
[✓] Assembling Android apk (63.56s)
[✓] Verify HelloSkip-release.apk 12.8 MB
[✓] Check Swift Package (0.15s)
[✓] Skip 0.8.55 checkup succeeded in 122.45s
I tried initializing a new Skip app project and compiled it fine with Xcode. I'm not sure what happened to my project, but it seems odd that it would fail to use the proper Java version.
Sorry for the trouble. We recently downgraded the target bytecode version because Android Studio currently only supports 17. All the Gradle modules (both our own, and your app's) need to harmonize on the JDK version, which appears to sometimes happen automatically and sometimes not (for reasons not yet known to us).
You should be able to fix the issue in your pre-existing project by editing your Android/app/build.gradle.kts file and adding the following inside the android block:
android {
kotlinOptions {
jvmTarget = libs.versions.jvm.get().toString()
}
… other stuff in android block is unchanged …
}
e.g., it should look like this:
Please let us know if that fixes it.
I'm afraid that didn't seem to do the trick. I made the addition (in the same spot as your screenshot) and am still getting the following:
* What went wrong:
Could not determine the dependencies of task ':app:packageDebug'.
> Could not create task ':app:compileDebugJavaWithJavac'.
> Failed to calculate the value of task ':app:compileDebugJavaWithJavac' property 'javaCompiler'.
> Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=17, vendor=any, implementation=vendor-specific} for MAC_OS on aarch64.
> No locally installed toolchains match and toolchain download repositories have not been configured.
Can you also try running the Xcode menu: File/Packages/Update to Latest Package Versions and see if that helps?
I did that and am still getting the same error.
GRADLE> FAILURE: Build failed with an exception.
GRADLE>
GRADLE> * What went wrong:
GRADLE> Could not determine the dependencies of task ':app:packageDebug'.
error: Could not determine the dependencies of task ':app:packageDebug'.
GRADLE> > Could not create task ':app:compileDebugJavaWithJavac'.
GRADLE> > Failed to calculate the value of task ':app:compileDebugJavaWithJavac' property 'javaCompiler'.
GRADLE> > Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=17, vendor=any, implementation=vendor-specific} for MAC_OS on aarch64.
GRADLE> > No locally installed toolchains match and toolchain download repositories have not been configured.
This is what I have for package dependencies (other than my own):
UPDATE:
I also tried deleting DerivedData and ran skip checkup again.
Hmm... is this a project you'd be able to just zip and send over to us? Might be faster than going back and forth. If not, I wonder if a fresh "skip init --open-xcode --appid=com.xyz.HelloSkip hello-skip HelloSkip" project compiles and runs from Xcode?
Interestingly, a new Skip project created from that exact command fails to build with a different error now:
GRADLE> > java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException:
com.android.ddmlib.InstallException: INSTALL_FAILED_VERSION_DOWNGRADE: Downgrade detected:
Update version code 1 is older than current 49
A skip checkup still seems to pass.
jeff@M3-MBP components-tester (debug) % skip checkup
[✓] Skip version 0.9.0 (= 0.9.0)
[✓] macOS version 14.5 (> 13.5.0)
[✓] macOS architecture: ARM
[✓] Swift version 5.10 (> 5.9.0)
[✓] Xcode version 15.4 (> 15.0.0)
[✓] Xcode tools SDKs: 9
[✓] Homebrew version 4.3.8 (> 4.1.0)
[✓] Gradle version 8.8 (> 8.6.0)
[✓] Java version 21.0.3 (> 21.0.0)
[✓] Android Debug Bridge version 1.0.41 (> 1.0.40)
[✓] Android Studio version: 2023.3
[✓] Android tools SDKs: 4
[✓] Resolve dependencies (18.23s)
[✓] Build hello-skip (7.65s)
[✓] Test Swift (4.65s)
[✓] Test Kotlin (30.73s)
[✓] Archive iOS ipa (16.82s)
[✓] Assemble HelloSkip-release.ipa 37 KB
[✓] Verify HelloSkip-release.ipa 37 KB
[✓] Assembling Android apk (78.11s)
[✓] Verify HelloSkip-release.apk 12.7 MB
[✓] Check Swift Package (0.21s)
[✓] Skip 0.9.0 checkup succeeded in 156.93s
I'm not getting this issue with my project, but the same one as described before.
I have created a very minimized version of that project (stripping out all of my own code) that still exhibits this behavior on my machine (Xcode 15.4, macOS 14.5, MBP M3 Max) even with the very latest package versions. I'm sending it your way now via email.
The new error you're seeing just means that you need to un-install any old version of that app from the Android emulator. It'll work after that.
On the topic of the existing project: first, thanks or sending it. Unfortunately it works for me right out of the box. But I do have a suggestion. Please try commenting out the "jvmToolchain" line in the "kotlin" section of the build.gradle.kts file:
import java.util.Properties
plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.android.application)
id("skip-build-plugin")
}
skip {
}
kotlin {
// jvmToolchain(libs.versions.jvm.get().toInt())
}
...
I commented out that line and re-compiled -- it worked, both in the minimized project I sent you and my full project.
🎉
Thank you so much for your help.
Is this something you'll need to revisit on your end, or is it okay to leave this commented out?
Hurray!
It's safe to keep commented out. You now have our recommended configuration. We haven't put up more docs and tooling around it yet because we're also preparing to move to the Kotlin 2 compiler, which is going to require additional changes. So we're trying to do all the tooling and docs at once.
不确定是否有关联,我在尝试修正 Android Studio 给出的相同报错时,进行了以下步骤:
brew install openjdk@17
for jdk in $(brew list | grep openjdk); do
# 将 Homebrew 安装的 JDK 链接到 `/Library/Java/JavaVirtualMachines` 目录下
sudo ln -sfn $HOMEBREW_PREFIX/opt/$jdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/$jdk.jdk
done
最后执行 $(/usr/libexec/java_home -v 17)/bin/java -version,看到输出为 openjdk version "17.0.13"
之后 Android Studio 的错误就消失了。
I'm not sure if it's related. When I tried to correct the same error given by Android Studio, I took the following steps:
brew install openjdk@17
for jdk in $(brew list | grep openjdk); do
# Link the JDK installed by Homebrew to the `/Library/Java/JavaVirtualMachines` directory
sudo ln -sfn $HOMEBREW_PREFIX/opt/$jdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/$jdk.jdk
done
Finally, execute $(/usr/libexec/java_home -v 17)/bin/java -version, and see the output as openjdk version "17.0.13"
After that, the error of Android Studio disappeared.
On the topic of the existing project: first, thanks or sending it. Unfortunately it works for me right out of the box. But I do have a suggestion. Please try commenting out the "jvmToolchain" line in the "kotlin" section of the build.gradle.kts file:
import java.util.Properties plugins { alias(libs.plugins.kotlin.android) alias(libs.plugins.android.application) id("skip-build-plugin") } skip { } kotlin { // jvmToolchain(libs.versions.jvm.get().toInt()) } ...
the jvm method applied on the version of libraries isn't working for me...