admin管理员组文章数量:1122832
I use android studio ladybug 24.2.1 In this version، GDK v-21 is Build-in how to change JDK for Android Studio from 21 to jdk 17.
JDK for Android toolchain is 17 and Android Studio is 21. I want to use JDK 17 for both of them.
This screenshot shows JDK 21 being used for Android Studio:
I use android studio ladybug 24.2.1 In this version، GDK v-21 is Build-in how to change JDK for Android Studio from 21 to jdk 17.
JDK for Android toolchain is 17 and Android Studio is 21. I want to use JDK 17 for both of them.
This screenshot shows JDK 21 being used for Android Studio:
- Why do you want to change the JDK Android Studio is running with. Android Studio comes with built-in JDK. I don't think you can change that. usually you only need to change the JDK gradle is running with - is that what you call "JDK for Android toolchain"? – Robert Commented Nov 22, 2024 at 15:19
5 Answers
Reset to default 1Check Installed JDKs, Ensure the desired JDK version is installed.
Open Android Studio Preferences
Open Android Studio. Go to Preferences -> Navigate to JDK Settings
In the Preferences window, go to: Build, Execution, Deployment > Build Tools > Gradle. Change the JDK Path
Under "Gradle JDK," click the dropdown and select your desired JDK version.
I had a similar issue with not being able to set it via studio so the easiest way
- Download jdk separately.
- Configure my project to use 17
- flutter config --jdk-dir yourJDK path
- Optionally (Some plugins may require) update
- sourceCompatibility JavaVersion.VERSION_17
- targetCompatibility JavaVersion.VERSION_17
- jvmTarget = '17'
To change Android Studio's JDK, follow these steps: 1 Go to File > Project Structure. 2 Select the SDK Location section in the list of the left. 3 Deselect the Use embedded JDK (recommended) option. 4 Enter the absolute path of your installed JDK in the text box 5 Digi also recommends you lower the default memory setting for Gradle (org.gradle.jvmargs property): ◦ Create a file called Gradle. Properties in the root of your project The reference I used is the website of my university.
If you use version manager like fvm,
Make sure your desired version set as global
do this command to change desired JDK version
flutter config --jdk-dir "C:\Program Files\Java\jdk-17.0.4"
Restart IDE or terminal, Happy coding
Here's what I did on my machine...
You can download Java 17 SDK based on your machine. Here's the link
After you download and install it.
Please go to your Android Studio's File > Project Structure...
Then select your installed Java SDK by this way:
Note: You can also verify there if you properly selected the corresponding Java SDK.
After selecting, click apply, and then ok.
Please consider doing File > Invalidate Caches...
After doing these things. Execute flutter doctor -v
again.
Make sure you set the proper PATH and JAVA_HOME in your ENVIRONMENT VARIABLES. Here's what I set for PATH: C:\Program Files\Java\jdk-17\bin
and for JAVA HOME: C:\Program Files\Java\jdk-17
it should be added in your system variables
section.
For instant checking of your PATH and JAVA_HOME setup,
In Windows, open your command prompt, then execute these commands:
for checking your PATH
where java
for checking your JAVA_HOME
echo %JAVA_HOME%
UPDATE
Here's the related answer to the OP's case: you may please visit this answer
I hope it helps!
本文标签: javahow to change JDK for Android Studio from 21 to jdk 17Stack Overflow
版权声明:本文标题:java - how to change JDK for Android Studio from 21 to jdk 17? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303932a1932054.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论