[Bug]: project fails to load in Android Studio
Is there an existing issue for this?
- [x] I have searched the existing issues
Is there a StackOverflow question about this issue?
- [x] I have searched StackOverflow
Is this an issue related to one of the samples?
- [x] Yes, this is a specific issue related to this samples repo.
Sample app
Jetcaster
What happened?
The project fails to load in Android Studio (latest stable release 2024.3.1):
Multiple build operations failed.
Could not create task ':core:data:compileDebugAndroidTestJavaWithJavac'.
Could not create task ':core:data-testing:compileDebugAndroidTestJavaWithJavac'.
Could not create task ':core:designsystem:compileDebugAndroidTestJavaWithJavac'.
Could not create task ':mobile:compileDebugAndroidTestJavaWithJavac'.
Could not create task ':core:data:compileDebugAndroidTestJavaWithJavac'.
Failed to calculate the value of task ':core:data:compileDebugAndroidTestJavaWithJavac' property 'javaCompiler'.
Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=17, vendor=any vendor, implementation=vendor-specific} for MAC_OS on aarch64.
No locally installed toolchains match and toolchain download repositories have not been configured.
I reported a similar issue with tv-samples JetStream back in October. https://github.com/android/tv-samples/issues/192 This works for me, (although not sure about the github actions yml)
git grep -l JDK | xargs sed -i 's/JDK 17/JDK 21/g'
git grep -l java-version | xargs sed -i 's/java-version: 17/java-version: 21/g'
git grep -l jvmToolchain | xargs sed -i 's/jvmToolchain(17)/jvmToolchain(21)/g'
git grep -l jvmTarget | xargs sed -i 's/jvmTarget = "17"/jvmTarget = "21"/g'
git grep -l JavaVersion | xargs sed -i 's/JavaVersion.VERSION_17/JavaVersion.VERSION_21/g'
I'm not doing a pull request, because I don't know enough about why this was hardcoded to java 17 in the first place. Maybe I'm missing something.
Relevant logcat output
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Did you try re-cloning the project? I've just clone and the project built
Re-cloning didn't help for me unfortunately.
Did you install your own java 17? I thought Android Studio used its own from:
% /Applications/Android\ Studio.app/Contents/jbr/Contents/Home/bin/javac -version
javac 21.0.5
Have you tried opening each project alone and not the entire project file?
I have the same issue.
Have you tried opening each project alone and not the entire project file?
Yes, that is what I do. I clone the repo outside of Android Studio and open each project alone in a new window.
- Jetcaster: fails with "Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=17, vendor=any vendor, implementation=vendor-specific} for MAC_OS on aarch64."
- Jetchat: works
- JetLagged: works
- JetNews: works
- Jetsnack: works
- Reply: works
I think I figured it out by comparing with other projects:
In core:data, core:data-testing, core:designsystem and mobile
Replace this (in build.gradle.kts):
kotlin {
jvmToolchain(17)
}
By this (inside the android { ... } section):
kotlinOptions {
jvmTarget = "17"
}
Seems related to #1526
replace kotlin { jvmToolchain(17) } with
kotlinOptions { jvmTarget = "17" }
in build.gradle.kts files.
it worked,ths
I was using the old version of Android Studio so it did not work, installed the latest version and it started working
Closing this issue based on the recently merged improvement. Please re-open if there's still problems!