Android Studio报错:Error:Could not find com.android.tools.build:gradle:4.9; peer not authenticated

本文详细介绍了Gradle的基本配置方法,包括正确的build.gradle文件示例,并针对Android Studio中常见的Gradle错误提供了有效的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

解决过程:

 

gradle的下载地址:http://services.gradle.org/distributions/

 

尝试1:https://blog.youkuaiyun.com/chy555chy/article/details/52789696

尝试2:https://www.jianshu.com/p/e371aa61d462

尝试3:https://blog.youkuaiyun.com/csdn_liuwen/article/details/62898129

https://blog.youkuaiyun.com/wenqiang0718/article/details/51274585

 

报错:Android studio 导入项目报 Error:Cause: peer not authenticated 异常

解决办法:

https://www.jianshu.com/p/5d482c73fd91

 

报错:transformDexWithInstantRunDependenciesApkForDebug

解决:https://blog.youkuaiyun.com/jiyilidenapianhai/article/details/80210455

 

各种问题,最后的最终解决是:

build.gradle要配置成如下内容:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter() {
            url "http://jcenter.bintray.com/"
        }
        maven {
            url 'https://maven.google.com'
        }
        maven { url 'https://jitpack.io' }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter() {
            url "http://jcenter.bintray.com/"
        }
        maven { url 'https://jitpack.io' }
        maven {
            url 'https://maven.google.com'
        }
    }

}
task clean(type: Delete) {
    delete rootProject.buildDir
}

 

且去掉勾选:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值