1.版本确认
Android Studio版本:2021.2.1
Gradle版本:7.5
Android Gradle Plugin Version:7.4.2
JDK版本:Java 11
SDK版本:33(Android 13.0)
2.网络配置
pluginManagement {
repositories {
maven { url "https://jitpack.io" }
maven { url 'https://maven.aliyun.com/repository/releases' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/public' }
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven { url "https://jitpack.io" }
maven { url 'https://maven.aliyun.com/repository/releases' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/public' }
google()
mavenCentral()
}
}
rootProject.name = "XXX"
include ':app'
3.关闭代理
4. 配置本地Gradle
Android Studio内置了Gradle,但是他在项目编译时才下载Gradle工具,but 不要抱有期望了,下不下来的,还是自己手动下载Gradle工具吧(注意下载对应版本,我这里的对应版本是7.5,若不清楚对应版本,可以看看前面的内容,查看自己需要的版本)。
Gradle版本下载:Gradle Distributions
下载完成后需要配置几个地方:
打开File —> Setting —> Build,Execution…… —> Build Tools —> Gradle。
a.设置Gradle user home为你安装的gradle目录;
b.设置下方User Gradle from为Specified location,并选择你的gradle目录;
c.选择Gradle JDK版本为Java 11
5. 修改字符集编码
打开File —> Setting —> 搜索coding —> Editor —> File Encodings,设置Global Encoding、Project Encoding和Default encoding for properties files为UTF-8,在上方“+”选择项目根路径,表示整个项目使用UTF-8编码。