android-studioandroid-studio-2.3

Android Studio shows an error when trying to use Embedded JDK instead of a custom install


After I updated to Android Studio 2.3, I haven't been able to use the embedded JDK. When I try to build the project, I get errors like this:

Error:The newly created daemon process has a different context than expected.
Java home is different.
Expecting: 'D:\Development\IDE\AndroidStudio\jre' but was: 'C:\Program Files\Java\jre1.8.0_121'.
Please configure the JDK to match the expected one.
<a href="open.project.structure">Open JDK Settings</a>

But the JAVA_HOME environment variable isn't defined, but I can still use the normal JDK any problems, so I don't believe that's a problem. Where does Android Studio find the JAVA_HOME that prevents me from using the embedded JDK?

I tried uninstalled the system JDK to get it to work, and I updated java, which lead to it pointing to the JRE. I then reinstalled the JDK and when I point to it, it works fine. But I want to use the embedded JDK. Any ideas?

I have tried setting JAVA_HOME in gradle.properties, as linked in comments, but it still shows the error.

The line I added was:

org.gradle.java.home=D:/Development/IDE/AndroidStudio/jre

It should make the embedded JDK work (and change JAVA_HOME in the IDE) but it doesn't. It still leads to the same error mentioned at the top of this post.

In the snippet it says jre, and that was because when I copied it, I had just uninstalled the JDK. Updating the JDK and Java resulted in JAVA_HOME being set to the JDK location, but it isn't defined as an environment variable. I tried deleting the JDK table in Android Studio's config folder, but it did not work.

And what it looks when I set the JDK to be the embedded:

Screenshot showing the embedded JDK being enabled


Solution

  • Try to reset your path of your updated JDK. and check it again. May be it will help you. Also clear your android studio temp cache and all.