How to setup Android Studio in El Capitan (OS X 10.11)?

后端 未结 3 1552
半阙折子戏
半阙折子戏 2021-02-01 08:38

Fresh install of El Capitan(10.11), tried to install Android Studio version 1.21.

Error:

Android Studio was unable to find a valid JVM. Please download it

3条回答
  •  死守一世寂寞
    2021-02-01 09:07

    You can either

    1. reintroduce Java6 or
    2. make Android Studio run on a more recent JDK

    If you favor the latter, you must first download and install the JDK8. Then unless Android Studio picks it up automatically, you'll have to configure it to use the newly installed JDK but not through its Info.plist as is often recommended but through a STUDIO_JDK environment variable (see link below for details). This can be done from the command line, in order to make sure Android Studio starts properly using JDK8:

    $ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.*_**.jdk
    $ open /path/to/Android\ Studio.app
    

    but you most likely want to also be able to open it from the GUI. In this case you can refer to this SO thread on how to create a plist launch agent which will be able to set the STUDIO_JDK variable for launchd by substituting the command in the linked answer snippet with

    launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.*_**.jdk
    

    (of course replace * with your currently installed version).

    Lastly, you should check the official documentation on the selection of the JDK for Android Studio for more details on the procedure, the drawbacks, the rationale behind the method I described above and information on how to set up the project (not just IDE) JDKs as well.

提交回复
热议问题