You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio导入旧项目报错:无法解析:classpath依赖(HTTP仓库问题)

解决Android Studio导入MyDialer项目的Gradle仓库协议错误

错误原因

Gradle 7及以上版本默认禁止使用HTTP这类不安全协议访问Maven仓库,而你的项目中配置的http://dl.bintray.com/amulyakhare/maven仓库使用HTTP协议,触发了安全限制。

解决方案

方案1:切换到HTTPS协议(推荐)

将目标仓库的URL替换为HTTPS协议地址,修改项目根目录下的build.gradle文件:

buildscript {
repositories {
    google()
    mavenCentral()
    maven {
        url 'https://dl.bintray.com/amulyakhare/maven' // 替换为HTTPS地址
    }
}
dependencies {
    classpath "com.android.tools.build:gradle:4.0.2"
    classpath 'io.realm:realm-gradle-plugin:3.2.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0"
}
}
plugins {
    id 'com.android.application' version '7.4.1' apply false
    id 'com.android.library' version '7.4.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
}

方案2:允许使用不安全协议(仅当无法切换HTTPS时使用)

在对应Maven仓库配置中添加allowInsecureProtocol = true,明确允许使用HTTP协议:

buildscript {
repositories {
    google()
    mavenCentral()
    maven {
        url 'http://dl.bintray.com/amulyakhare/maven'
        allowInsecureProtocol = true // 添加该行开启不安全协议允许
    }
}
dependencies {
    classpath "com.android.tools.build:gradle:4.0.2"
    classpath 'io.realm:realm-gradle-plugin:3.2.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0"
}
}
plugins {
    id 'com.android.application' version '7.4.1' apply false
    id 'com.android.library' version '7.4.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
}

额外提示

你项目的buildscript中配置的Gradle插件版本(4.0.2)和plugins块中声明的版本(7.4.1)不一致,这可能引发其他兼容性问题,建议统一为同一稳定版本。

内容的提问来源于stack exchange,提问作者D.J

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 14:02:08