Search code examples
androidandroid-studiojava-8java-7java-6

Android Studio cannot use secure connection for update, complaining the use of Java 6


In Android Studio's Preferences -> Appearance & Behavior -> System Settings -> Updates, I tried to enable the Use secure connection option:

enter image description here

But when I clicked the Apply button, the error "Secure connection is not supported on Java 6" showed up:

enter image description here

I checked the JDK location setting in Project Structure, and it's /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home:

enter image description here

It seems that I'm using Java 7, not Java 6. Then why the secure connection setting complains about not supported by Java 6?


In case needed, below is the installed JDKs on my machine: enter image description here

The first one 1.6.0.jdk is from Apple, and the other 3 are from Oracle.


Solution

  • This problem occurs on Mac OS. The project JDK (the JDK used for compiling your code) is different from the IDE JDK (the JDK used to run the IDE)

    Your project JDK is 7, but your IDE JDK is 6.

    For your case, you can add an environment variable for the IDE (by Terminal) as below:

    export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk
    

    Check these documents for more information:

    http://tools.android.com/tech-docs/configuration/osx-jdk

    http://tools.android.com/tech-docs/configuration

    Happy coding!