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
Android Studio 4.1: google-java-format option not appearing in "Other Settings" #536
Comments
when I upgraded Android Studio 4.0 to 4.1 I got this exception while loading google-java-format 1.9.0.0 version plugin.
|
upvote for AS 4.1 |
2 similar comments
upvote for AS 4.1 |
upvote for AS 4.1 |
Google Java Format 1.9 requires JDK 11, and apparently Android Studio uses/bundles JDK 8 (JBR 8). So the problem isn't an incompatibility with AS 4.1 in itself, but incompatibility with the bundled JDK, and updating your Android Studio probably means you reinstalled and/or updated the GJF plugin to 1.9. According to https://www.reddit.com/r/android_devs/comments/hiv4d7/using_a_jdk_other_than_the_one_bundled_with/fwip1qz/ you should be able to easily run Android Studio with JDK 11, through https://plugins.jetbrains.com/plugin/12836-choose-runtime Either that or downgrade the GJF plugin to 1.8. |
Is it somehow possible to make the plugin compatible with the JDK that ships with Android Studio by default? Getting other engineers to adjust their IDE settings just to make a formatting plugin work is a huge headache. Problems will get misidentified, etc.. Additionally, there is no option to downgrade from within AS. I fully understand this on Android Studio shipping with a antique JDK and we should somehow let the Android Tools team know about this, but for the current state of affairs, it would be great to have a out-of-the box working version of the formatter. PS: The formatter plugin in AS mentions a bump to version 1.9 of the plugin but does not mention the new JDK requirement in any shape or format. This should be included, really. |
The workaround I'd personally use is to:
|
Unfortunately there's no way to mark a plugin as only being compatible with a given JDK. If there was such a way, I could tell it only only use 1.8 unless you have a Java 11 JDK. But there's not AFAIK. I suppose I could just mark 1.9 as incompatible with Android Studio entirely? But that would prevent anyone from using it. But I suppose Android Studio users probably aren't writing a lot of Java 14 code, so don't really need gjf 1.9... I don't really know what the right thing to do here is. |
Revert the changes in 1.9 that made it incompatible with JDK 1.8? |
@plumpy WDYT about reverting the plugin back to compatibility with JDK 1.8? |
IntelliJ has been shipping with a Java 11 JRE since 2019.2. Android Studio started shipping with Java 11 in 4.2 (which uses the 2020.2 API). There's no way I can find to say "this plugin is compatible with API 2019.2+ except for Android Studio, where it's only compatible with 2020.2+". I can't even mark it as "incompatible with Android Studio" because I don't want to break compatibility for all the IntelliJ users (which has literally 10x as many users as Android Studio). So I'd recommend either manually downgrading the plugin or upgrading to AS 4.2 canary. Sorry, I know it's frustrating. |
@plumpy What part of Would downgrading the requirement to JDK 8 in the plugin break IntelliJ users? I'd assume JDK 11 can execute JDK8 code just fine? |
I found a solution。 |
It's required JDK 11 since release 1.8, as part of supporting formatting Java 11+ language features and minimizing the number of versions of the javac APIs it neds to remain compatible with: 3c191c1 |
tried downgrading to 1.8 from here - https://github.com/google/google-java-format/releases/tag/google-java-format-1.8 install from disk and choosing google-java-format-1.7.tar.gz doesn't work @plumpy .. any insights why ? |
maybe you should download the jetbrains plugin v1.7 from https://plugins.jetbrains.com/plugin/8527-google-java-format |
Since newer versions of Android Studio ship with Java 11, this shouldn't be an issue anymore. |
I upgraded from Android Studio 4.0 to 4.1 and the google-java-format plugin seemed to stop working. At first, it was because all my plugins were reset so I reinstalled the plugin (1.9.0.0) from Marketplace. As per the README for Intellij setup, I tried to go to "Other Settings" in my project settings to enable google-java-format for my project. However, the option doesn't appear where it used to be.
On my other machine with Android Studio 4.0 and google-java-format v1.7.0.4 installed, the option is there (see below).
Has there been a regression in compatibility with Android Studio 4.1?
The text was updated successfully, but these errors were encountered: