Mac environment configuration JAVA, Android environment variables

Mac environment configuration JAVA, Android environment variables

1. Download Java and AndroidSDK

Download AndroidSdkDownload JavaSDK

2. After the installation is complete, find the corresponding installation directory

3. Configure environment variables:

  1. Open the Terminal terminal tool on Mac and execute: ls -a
    insert image description here

  2. If there is a .bash_profile file in the current path, ignore this step. If there is no such file, you need to enter the command in the terminal: touch .bash_profile;

  3. input the command:

    open .bash_profile 
    

    Open the .bash_profile file for editing;

  4. Enter the following into the editor:

    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
    PATH=$JAVA_HOME/bin:$PATH:.
    CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
    
    ANDROID_HOME=/Users/jiabaokang/Library/Android/sdk
    PATH=$PATH:$ANDROID_HOME/build-tools/30.0.2
    PATH=$PATH:$ANDROID_HOME/tools
    PATH=$PATH:$ANDROID_HOME/platform-tools
    
    PATH=$JAVA_HOME/bin:$PATH:
    export JAVA_HOME
    export CLASSPATH
    export ANDROID_HOME
    export PATH
    export PATH=${
          
          PATH}
    
    执行保存(command+s)
    
  5. Execute in terminal:

    source .bash_profile
    

    The configuration can take effect immediately

  6. Note:
    (1) For the SDK path of JAVA_HOUME in the article (/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home), please use the actual path corresponding to your own Java sdk version, do not copy and use directly;

    (2) For the SDK path of ANDROID_HOUME in the article (/Users/jiabaokang/Library/Android/sdk), please use the actual path corresponding to your own Android SDK version, do not copy and use it directly;

    PATH= P A T H : PATH: PATH: ANDROID_HOME/build-tools/30.0.2; The later version of build-tools also needs to be replaced with its own corresponding version

    Sometimes after configuring the environment variable, the problem that the Java or adb command does not take effect when the terminal is closed

    You can refer to another article: Reopening the terminal after Mac adb configures environment variables does not take effect

Guess you like

Origin blog.csdn.net/jiabaokang/article/details/110676593