Skip to content

[Bug]: project fails to load in Android Studio #1539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks done
gramound opened this issue Mar 7, 2025 · 8 comments
Open
4 tasks done

[Bug]: project fails to load in Android Studio #1539

gramound opened this issue Mar 7, 2025 · 8 comments
Assignees
Labels
bug Something isn't working triage me Issue that needs to be triaged

Comments

@gramound
Copy link

gramound commented Mar 7, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Is there a StackOverflow question about this issue?

  • I have searched StackOverflow

Is this an issue related to one of the samples?

  • 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. android/tv-samples#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

  • I agree to follow this project's Code of Conduct
@gramound gramound added bug Something isn't working triage me Issue that needs to be triaged labels Mar 7, 2025
@gramound gramound changed the title [Bug]: [Bug]: project fails to load in Android Studio Mar 7, 2025
@JamesDownes5
Copy link

Did you try re-cloning the project? I've just clone and the project built

@gramound
Copy link
Author

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

@kevinhui98
Copy link

Have you tried opening each project alone and not the entire project file?

@kaamel
Copy link

kaamel commented Apr 8, 2025

I have the same issue.

@gramound
Copy link
Author

gramound commented Apr 8, 2025

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

@gramound
Copy link
Author

gramound commented Apr 8, 2025

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

@gramound
Copy link
Author

gramound commented Apr 8, 2025

Seems related to #1526

@luciferChou
Copy link

replace kotlin { jvmToolchain(17) } with
kotlinOptions { jvmTarget = "17" }
in build.gradle.kts files.
it worked,ths

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage me Issue that needs to be triaged
Projects
None yet
Development

No branches or pull requests

6 participants