'"Unable to resolve dependency for" after performing Build/Make Project after update to Bumblebee
After updating Android Studio to Bumblebee 2021.1.1 Patch 2 I encountered failures that I hadn't before. For example, after a Build/Make Project attempt under Build/Sync there are 23 messages of the form:
Failed to resolve: com.squareup.leakcanary:leakcanary-android:2.8.1 Show in Project Structure dialog Affected Modules: app
I searched for com.squareup.leakcanary and found that it is not at the repository set in build.gradle, so I added that repository to my build.gradle file as the second URL under allprojects/repositories as I believe that Declaring repositories intends:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
//jcenter()
mavenCentral()
}
dependencies {
def nav_version = "2.4.1"
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
//jcenter()
google()
maven { url 'https://maven.google.com' }
maven { url 'https://mvnrepository.com/artifact/com.squareup.leakcanary'}
//maven { url 'https://mvnrepository.com/'}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The following warning is found under Build Output:
Could not HEAD 'https://mvnrepository.com/artifact/com.squareup.leakcanary/com/squareup/leakcanary/leakcanary-android/2.8.1/leakcanary-android-2.8.1.pom'. Received status code 403 from server: Forbidden Disable Gradle 'offline mode' and sync project
Clicking on the URL in that message results in the following from mvnrepository.com:
Not Found For request 'GET /com/squareup/leakcanary/leakcanary-android/2.8.1/leakcanary-android-2.8.1.pom'
Obviously the process made a call that was rebuffed. The following line for leakcanary is in my app build.gradle (app) file:
// debugImplementation because LeakCanary should only run in debug builds.
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
According to Getting started that is all that is required to use leakcanary, which is why I use it as an example, it fails now when it worked before as shown on that web page.
Something happened with this update that led to gradle not being able to resolve dependencies that it did previously. I have 23 of these to deal with and would like to understand what is going on and what I can't see in the Bumblebee update information or the Gradle documentation. I've read Verifying dependencies, but a resolution does not jump out at me.
All of the stackoverflow search results mentioned doing one of the following that I have ensured were done:
- Offline mode is disabled
- Performed File/Invalidate caches
- Commented out jcenter() as its no longer receiving updates
- Updated current revisions in build.gradle (app)
- Performed Build/Clean Project
- Followed all suggestions in Bumblebee update and subsequent ones identified in build.gradle (app) for the individual dependency revisions
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
