Android Studio在Intel i7款MacBook Pro上报错找不到指定Gradle插件
问题解答
是否与处理器有关?
这个问题和处理器本身无关。核心原因是gradle-bintray-plugin依赖的JCenter仓库已在2021年停止服务,不再提供插件包的拉取服务。不同芯片设备的差异仅在于:M1/M2/AMD设备可能之前已缓存过该插件的本地副本,而Intel设备的缓存恰好失效或从未缓存过,因此触发了找不到依赖的错误。
正确修复方案
1. 替换废弃的Bintray插件
gradle-bintray-plugin已被官方废弃,建议改用Gradle自带的Maven Publish插件替代:
- 修改项目根目录的
build.gradle(Groovy)或build.gradle.kts(Kotlin)中的插件依赖:
原Bintray插件引用:
替换为Maven Publish插件(无需额外仓库,Gradle自带):classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'classpath 'org.gradle.plugins:maven-publish:11.0.0' // 版本需与你的Gradle版本适配,Gradle 8.x推荐用10.0.0+ - 在模块的
build.gradle中,将原Bintray上传配置替换为Maven Publish的配置示例:publishing { publications { release(MavenPublication) { from components.release // 对应Android的release变体 // 配置你的包信息 groupId = "com.yourcompany" artifactId = "your-library" version = "1.0.0" } } // 配置要上传的仓库(本地或私有仓库) repositories { maven { url = uri("$projectDir/repo") // 本地仓库示例 } } }
2. 彻底清理缓存并同步
执行以下操作确保旧缓存被完全清除:
- 在终端运行Gradle命令:
./gradlew clean build --refresh-dependencies - 在Android Studio中执行:
File -> Invalidate Caches... -> 勾选Clear file system cache and local history -> 点击Invalidate and Restart
3. 移除无效仓库配置
检查项目的settings.gradle(或settings.gradle.kts),移除已失效的jcenter()仓库引用,替换为可用仓库:
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() // 其他必要的私有仓库 } }
内容的提问来源于stack exchange,提问作者BalasubramaniG
相关产品推荐
相关产品推荐

