Android Studio installation and setting SDK, Gradle (domestic source), AVD download directory detailed tutorial

Local environment: win11 Home Edition
Android Studio version: android-s studio-2022.2.1.20-windows

Install Android Studio

Official website download

android studio official website

Install Android Studio

  • Create a folder on the installation target disk, do not have a Chinese folder, and do not have a space in the folder name.
  • This installation is installed in a VMware virtual machine. There is only one C drive and no other drives, so the custom installation directory is created under the C drive and the
    insert image description here
    insert image description here
    insert image description here
    insert image description here
    insert image description here
    insert image description here
    Android studio installation is complete.

insert image description here
insert image description here
The above pop-up window may appear slower
insert image description here

Set the JDK version used by Android Studio's gradle

insert image description here

The above uses the JDK that comes with the AS. Because the gradle version 8.0 used by AS2022.2.1.20, the JDK version installed on this machine is java8, which cannot be used, so choose the default JDK version java17 that comes with the AS.
insert image description here

Set the SDK download directory of Android Studio

insert image description here
The above installs the Android SDK and the packages required to install the Android virtual device

Set virtual device memory

insert image description here
Ready to install
insert image description here
insert image description here
insert image description here
insert image description here
and wait for completion
insert image description here

Set up Android Studio

customize --> All Settings can also enter the settings in File --> Settings after opening the project
insert image description here

Set the Android SDK directory of Android Studio

customize --> All Settings --> Appearance & Behavior --> System Settings --> Android SDK
insert image description here

You can see that the SDK directory has been set up during installation and some things have been downloaded to this directory.
insert image description here

Set the Gradle directory for Android Studio

customize --> All Settings --> Build, Execution, Deployment --> Build Tools --> Gradle
insert image description here
setting environment variablesGRADLE_USER_HOME, set the Gradle directory path selected above as an environment variable: C:\AndroidStudio\Gradle
insert image description here
will automatically download gradle to the custom gradle directory after creating a new project, which is also the directory configured by the environment variable.
insert image description here
Android Studio will download gradle to C:\ Under AndroidStudio\Gradle\wrapper\dists\gradle-8.0-bin\ca5e32bp14vu59qr306oxotwh, you can download the corresponding version from the gradle official website to this directory, and then restart Android Studio.
Note: Ask AS to download and confirm the directory (the directory with the combination of numbers and letters at the last level), and then put the corresponding version of the gradle compressed package that you downloaded in this directory. After restarting AS, it will not be downloaded again.
Gradle official website
insert image description here
insert image description here
insert image description here
Close Android Studio, manually download gradle 8.0 version and put the compressed package into this directory, restart Android Studio,
insert image description here
set the source of domestic Alibaba Cloud,
find C:\AndroidStudio\Gradle\wrapper\dists\gradle-8.0-bin\ca5e32bp14vu59qr306oxotwh\ gradle-8.0\init.d\, there is a readme file under this folder, telling us that we can add it under this foldergradleinit script (eginit.gradle), each of which will be executed at build time.
readme: You can add .gradle (e.g. test.gradle) init scripts to this directory. Each one is executed at the start of the build.
Create a gradle script named init.gradle

allprojects{
    
    
    repositories {
    
    
        def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
        def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
        all {
    
     ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
    
    
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2')) {
    
    
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
    
    
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
                    remove repo
                }
            }
        }
        maven {
    
    
                url ALIYUN_REPOSITORY_URL
            url ALIYUN_JCENTER_URL
        }
    }
}

After restarting Android Studio again, gradle downloads dependencies very quickly.

Set the AVD directory of Android Studio

Projects --> More Actions --> Virtual Device Manager
insert image description here
insert image description here
can see that the virtual device has been installed when Android Studio was just installed, and the installation directory is in the default location:C:\Users\jx.android\avd
insert image description here
Through the Virtual Device Manager management of Android Studio, delete the device first, and then pass the environment variableANDROID_SDK_HOMETo specify the AVD installation directory

The virtual device has been deleted insert image description here
insert image description here
and the environment variable has been addedANDROID_SDK_HOME, the directory is set to: C:\AndroidStudio\AVD
insert image description here
to install the virtual device must be installed firstHAXM, otherwise when you add a virtual device later, it will prompt that HAXM is not installed.
insert image description here
Next, continue to add a new virtual device in the Virtual Device Manager.
insert image description here
Select which device
insert image description here
to add according to your needs. It is mentioned that it needs to be installed in HAXM first.
insert image description here
Install HAXM first . After the HAXM installation is complete, download
insert image description here
Android
insert image description here
6
insert image description here
and select the system image.
insert image description here
insert image description here
ANDROID_SDK_HOMEThe set directory: C:\AndroidStudio\AVD
insert image description here
Create another one, or here,
insert image description here
so far all installation settings are complete

Guess you like

Origin blog.csdn.net/weixin_44341110/article/details/131811275