Local environment: win11 Home Edition
Android Studio version: android-s studio-2022.2.1.20-windows
Article directory
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
Android studio installation is complete.
The above pop-up window may appear slower
Set the JDK version used by Android Studio's gradle
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.
Set the SDK download directory of Android Studio
The above installs the Android SDK and the packages required to install the Android virtual device
Set virtual device memory
Ready to install
and wait for completion
Set up Android Studio
customize --> All Settings can also enter the settings in File --> Settings after opening the project
Set the Android SDK directory of Android Studio
customize --> All Settings --> Appearance & Behavior --> System Settings --> Android SDK
You can see that the SDK directory has been set up during installation and some things have been downloaded to this directory.
Set the Gradle directory for Android Studio
customize --> All Settings --> Build, Execution, Deployment --> Build Tools --> Gradle
setting environment variablesGRADLE_USER_HOME, set the Gradle directory path selected above as an environment variable: C:\AndroidStudio\Gradle
will automatically download gradle to the custom gradle directory after creating a new project, which is also the directory configured by the environment variable.
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
Close Android Studio, manually download gradle 8.0 version and put the compressed package into this directory, restart Android Studio,
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
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
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
and the environment variable has been addedANDROID_SDK_HOME, the directory is set to: C:\AndroidStudio\AVD
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.
Next, continue to add a new virtual device in the Virtual Device Manager.
Select which device
to add according to your needs. It is mentioned that it needs to be installed in HAXM first.
Install HAXM first . After the HAXM installation is complete, download
Android
6
and select the system image.
ANDROID_SDK_HOMEThe set directory: C:\AndroidStudio\AVD
Create another one, or here,
so far all installation settings are complete