如何修复Could not find com.eightbitlab:blurview:1.6.3错误?
问题:Gradle构建失败,无法解析com.eightbitlab:blurview:1.6.3依赖
错误日志
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'spreadfoundation'. > Could not resolve all files for configuration ':classpath'. > Could not find com.eightbitlab:blurview:1.6.3. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/eightbitlab/blurview/1.6.3/blurview-1.6.3.pom - https://jcenter.bintray.com/com/eightbitlab/blurview/1.6.3/blurview-1.6.3.pom Required by: project : * Get more help at https://help.gradle.org BUILD FAILED in 12s at makeError (C:\Users\Victor\Documents\Spread\spread-foundation\node_modules\execa\index.js:174:9) at C:\Users\Victor\Documents\Spread\spread-foundation\node_modules\execa\index.js:278:16 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async runOnAllDevices (C:\Users\Victor\Documents\Spread\spread-foundation\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5) at async Command.handleAction (C:\Users\Victor\Documents\Spread\spread-foundation\node_modules\@react-native-community\cli\build\index.js:192:9) info Run CLI with --verbose flag for more details.
当前根build.gradle配置
buildscript { ext { buildToolsVersion = "30.0.3" minSdkVersion = 21 compileSdkVersion = 34 targetSdkVersion = 34 } repositories { google() jcenter() } dependencies { // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "30.0.3" minSdkVersion = 21 compileSdkVersion = 34 targetSdkVersion = 34 } repositories { google() jcenter() } dependencies { classpath 'com.eightbitlab:blurview:1.6.3' classpath("com.android.tools.build:gradle:8.0.0") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } google() jcenter() maven { url 'https://www.jitpack.io' } } } //implementation 'com.facebook.fresco:sthetho:2.0.0' //classpath("com.android.tools.build:gradle:8.0.0") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() mavenCentral() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } google() jcenter() maven { url 'https://www.jitpack.io' } } }
背景信息
- 应用创建于2020/21年,此前已升级过API级别,本次再次升级时触发该问题
- 已知JCenter已关闭,查阅过官方相关说明及2021、2023年的同类问题,未找到有效解决方法
- 已为多个模块添加namespace配置
修复方案
1. 修复buildscript嵌套错误
你的根build.gradle存在buildscript嵌套buildscript的无效写法,这会导致依赖配置无法被正确识别。需要删除内层嵌套的buildscript块,将内容合并到外层。
2. 替换JCenter为有效仓库
JCenter已停止服务,需将mavenCentral()添加到buildscript和allprojects的repositories中,替换或移除jcenter()。com.eightbitlab:blurview的新版本已迁移至mavenCentral,确保仓库配置正确。
3. 调整blurview依赖的位置
com.eightbitlab:blurview是应用级依赖,不属于buildscript的classpath依赖,必须移至模块级build.gradle(如app/build.gradle)的dependencies块中,而非根项目的buildscript内。
修正后的根build.gradle示例
buildscript { ext { buildToolsVersion = "30.0.3" minSdkVersion = 21 compileSdkVersion = 34 targetSdkVersion = 34 } repositories { google() mavenCentral() // 替换jcenter(),或保留jcenter并添加内容过滤 // 若必须保留jcenter,可添加过滤仅允许特定依赖: // jcenter { // content { // includeGroupByRegex 'com\\.eightbitlab.*' // } // } } dependencies { classpath("com.android.tools.build:gradle:8.0.0") // 注意:blurview依赖不应出现在此处 } } allprojects { repositories { mavenLocal() mavenCentral() maven { url("$rootDir/../node_modules/react-native/android") } maven { url("$rootDir/../node_modules/jsc-android/dist") } google() maven { url 'https://www.jitpack.io' } // 同样替换jcenter为mavenCentral,或按需过滤 } }
4. 在模块级build.gradle中添加依赖
打开app/build.gradle,在dependencies块内添加:
implementation 'com.eightbitlab:blurview:1.6.3' // 可选:尝试升级到最新兼容版本,如1.7.2 // implementation 'com.eightbitlab:blurview:1.7.2'
5. 同步并清理缓存
- 执行Gradle同步操作(Android Studio中点击"Sync Project with Gradle Files")
- 运行命令清理缓存并重新构建:
# Windows gradlew.bat clean build --refresh-dependencies # macOS/Linux ./gradlew clean build --refresh-dependencies
内容的提问来源于stack exchange,提问作者Victor Almeida
相关产品推荐
相关产品推荐

