文章目录
刚安装android studio的话,如果直接创建项目,基本gradle编译不过去,会报错。
plugin:com.android.application
最开始我一直报错找不到插件,因为我这个版本写的是8.2.2,好像就没这个找不到,我改成了8.0
project层的文件build.gradle
xml
plugins {
id 'com.android.application' version '8.0.0' apply false
}
gradle换源
这里大致修改几个地方,主要其实就是连不上google,换个源,我的adnroid studio版本是2023.11
项目选择java、build.gradle,不要选kts
project项目的文件settings.gradle
里面换一下源
java
pluginManagement {
repositories {
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()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
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()
maven {url = "https://jitpack.io"}
}
}
rootProject.name = "FileExplorer"
include ':app'
gradle下载
在AS的settings里面degradle设置一下路径,就用项目自己的.gradle路径。可以提前下载好,在文件gradle-wrapper.properties
设置一下路径distributionUrl
distributionUrl=file:///C:/Users/xxx.../.gradle/wrapper/dists/gradle-8.2-bin.zip
AVD启动电脑蓝屏
可能是SDK没有下载模拟器,在SDK anager里面的SDK Tools下载类似这个名字的东西就可以了
- Adnroid Emulator hypervisor xxx
- Intel x86 Emulator Accelerator(HAXM installer) xxx