Android studio项目运行碰到的构建问题

379 阅读1分钟

1gradle下载失败

国内无法访问android studio中默认的gradle仓库,需要修改成国内源。

阿里云:mirrors.aliyun.com/macports/di…

腾讯云:mirrors.cloud.tencent.com/gradle/

gradle版本建议使用-all版本。

修改gradle/wrapper/gradle-wrapper.properties中

distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-8.11.1-all.zip

2maven仓库配置报错Unexpected tokens (use ';' to separate expressions on the same line)

//之前一般是这么配置,在使用8.11.1后报错,暂不清楚为什么报错
maven {
    url "https://maven.aliyun.com/repository/public"
}
//改成如下即可
maven {
    url = uri("https://maven.aliyun.com/repository/public")
}

3在build.gradle文件中添加maven仓库报错

Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle.kts'

之前都是在build.gradle中配置仓库路径,猜测是新版本要求,建议在settings.gradle文件中配置仓库路径了,改过去就行