Status Update
Comments
uc...@google.com <uc...@google.com>
xa...@google.com <xa...@google.com>
sr...@google.com <sr...@google.com> #2
Changing the value in the Project Structure dialog in effect changes the value of the "Android Studio: " location in this warning. Changing the boot jdk will have the effect of setting up some environment variables and system properties, changing the value of the "Gradle: " location. I think that the changes you saw are consistent with this, but we need to improve this message.
If you are calling Gradle from Android Studio alone, and not from the command line or other ways, then you can ignore this warning.
gu...@gmail.com <gu...@gmail.com> #3
I verified that by adding the following to the app's build.gradle.
println('Path used by gradle: ' + System.getProperty('java.home'))
Both from within AS and from terminal, it does indeed use the same JDK in my case. I actually had to set the correct value in Project Structure dialog so that it does not spawn multiple processes.
Default jdk used by gradle in the terminal can be found out by executing `/usr/libexec/java_home`
sr...@google.com <sr...@google.com>
da...@google.com <da...@google.com> #4
sr...@google.com <sr...@google.com>
uc...@google.com <uc...@google.com>
je...@google.com <je...@google.com>
ku...@gmail.com <ku...@gmail.com> #6
I think this is more of a bug than a wrong message. How could you possibly setup your project in such a way that running gradle from the command line would result in using the JDK inside of /Applications/Android Studio.app/ ?
I do not get this warning, but some of my coworkers do. I have sat down and tried to see what is different to no avail.
- Our AS version is the same
- Our project is the same
- Our `Switch Boot JDK` location is the same
- Our `Project Structure` -> `JDK Location` is the same
- Our JAVA_HOME variables are not set
- Output of System.getProperty('java.home') inside build.gradle is the same (from CLI and AS build window)
Any thoughts?
sr...@google.com <sr...@google.com> #7
The new message is like this:
Android Studio is using the following JDK location when running Gradle:
${jdkPath}
Using different JDK locations on different processes might cause Gradle to
spawn multiple daemons, for example, by executing Gradle tasks from a terminal
while using Android Studio.
The original message was intended to be a warning when AS suspects that it is using a different JDK to the one used while running Gradle in the CLI. Changing the JDK on the Project Structure dialog has no effect on how Gradle is run from the CLI. If you want to modify what JDK is used, then you can change it by modifying JAVA_HOME in a terminal and run it from there or set it up in one of the Gradle files (
It is possible that some of your coworkers in
gu...@gmail.com <gu...@gmail.com> #8
sr...@google.com <sr...@google.com> #9
It tries to generate a new process with its own environment and from there it uses JAVA_HOME, if that is not defined then it uses java.home from the java system properties.
gu...@gmail.com <gu...@gmail.com> #10
If you have a mac, you can compare the output of the above process with the output of `/usr/libexec/java_home` which determines the JDK used on CLI.
sr...@google.com <sr...@google.com> #11
It changes depending on the OS version and the application used as terminal, even for default configurations on different versions of Mac OS. So instead of trying to guess we show that more generic message and use the current environment. There are many possible ways Gradle can be run and there is not a reliable way that AS can check if there will be issues when running other processes.
This warning must be considered just as a reminder that multiple daemons could be running and that this could be one of the causes. Having a different JDK it is not a problem by itself, so hence the warning and that is why it can be disabled.
Description
The Gradle JDK is configured by changing it in Project Structure -> SDK Location -> JDK Location and is set to the /Library one.
Checked that the AS JDK is set to bundled one by checking the boot jdk (cmd+shift+a -> switch boot jdk)
Below is the warning shown after a sync
Android Studio and Gradle are using different locations for the JDK.
Android Studio: /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home
Gradle: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home
Using different JDK locations might cause Gradle to spawn multiple daemons
when executing tasks for Android Studio and other external processes.
More info...
Select a JDK from the File System
Do not show this warning again
Installation details:
Android Studio 4.0 Canary 1
Build #AI-192.6817.14.36.5959023, built on October 22, 2019
Runtime version: 1.8.0_212-release-1586-b4-5784211 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15
GC: ParNew, ConcurrentMarkSweep
Memory: 2014M
Cores: 4
Registry: ide.new.welcome.screen.force=true, ide.suppress.double.click.handler=true
Non-Bundled Plugins: com.urswolfer.intellij.plugin.gerrit, org.intellij.plugins.markdown\
Gradle version: 5.6.3
AGP: 4.0.0-alpha01