Android Studio IDE with private jre/jdk? OSX

后端 未结 5 772
终归单人心
终归单人心 2020-12-18 04:50

I\'m running OSX 10.8 and was trying to run the Android Studio app bundle using a private jdk rather than one that is globally installed.

EDIT: I don\'t have any ja

相关标签:
5条回答
  • 2020-12-18 05:02

    For getting the app to start:

    In spotlight see if you have a "java preferences".
    From there you can add you own jdk/jre and let it be the one used by osx.
    If you dont have it, you will need to install a java jre as in this question : How to get back Java Preferences in OS X with Java for OS X 2012-006?

    Then you should be able to get the "java preferences" app and add your custom jdk there

    This should help you get started with project related sdk stuff.

    1. Open your project with modules
    2. select a module in the project pane
    3. right click > " open module settings"
    4. select SDKs on the modal that appears
    5. click the + icon (middle content area on the top)
    6. select jdk
    7. target the folder "to the JDK [you] have on disk"
    8. hit choose
    0 讨论(0)
  • 2020-12-18 05:08

    I just check the executable script that starts android-studio, if you are arleady familiar with intellijIdea it is the same.

      # ---------------------------------------------------------------------
      # Locate a JDK installation directory which will be used to run the IDE.
      # Try (in order): STUDIO_JDK, JDK_HOME, JAVA_HOME, "java" in PATH.
      # ---------------------------------------------------------------------
      if [ -n "$STUDIO_JDK" -a -x "$STUDIO_JDK/bin/java" ]; then
        JDK="$STUDIO_JDK"
      elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then
        JDK="$JDK_HOME"
      elif [ -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then
        JDK="$JAVA_HOME"
      else
        JAVA_BIN_PATH=`which java`
        if [ -n "$JAVA_BIN_PATH" ]; then
          if [ "$OS_TYPE" = "FreeBSD" -o "$OS_TYPE" = "MidnightBSD" ]; then
            JAVA_LOCATION=`JAVAVM_DRYRUN=yes java | "$GREP" '^JAVA_HOME' | "$CUT" -c11-`
    

    As written in the comments of the bash scripts, just add a STUDIO_JDK environment variable with the absolute path of the desired JDK.

    This is my ideaj.sh bash script which i stored in /etc/profile.d

    export IDEA_JDK=/opt/jdk1.7.0_71
    export STUDIO_JDK=/opt/jdk1.7.0_71
    

    Add to /etc/bash.bashrc to automatically set the variables at every login.

    source /opt/profile.d/ideaj.sh
    

    All this should be applied to linux, on OS X can be a little different, but the theory is the same.

    0 讨论(0)
  • 2020-12-18 05:22

    Another solution for OSX: go to the Applications folder, right click on Android Studio, choose "Show Package Contents".

    Open the Info.plist file. Locate the JVMVersion key, and set the string value you need.

    In my case, I needed to be 1.7 and up to be able to run the RoboVM plugin, and the value was 1.6*,1.7+, so I left it only on 1.7+.

    Restart Android Studio and it should be using the version of the JVM you need.

    This works if you have root access on your Mac.

    0 讨论(0)
  • 2020-12-18 05:23
    $ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
    $ open /Applications/Android\ Studio.app
    

    here is explain link

    0 讨论(0)
  • 2020-12-18 05:24

    Set the variable; ANDROID_STUDIO_JDK and use it for the path to your JDK.

    source: http://www.reddit.com/r/Android/comments/1ee2ea/google_announces_android_studio_a_new_development/c9zfklt

    0 讨论(0)
提交回复
热议问题