Search code examples
android-studiogradlepluginsandroid-gradle-pluginjava-17

gradle build fails on Android Studio : com.android.application cannot be found for any version


When I do gradle build it gets stuck on this for a while:

Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
<-------------> 0% CONFIGURING [21s]
> root project > Resolve dependencies of detachedConfiguration1 > com.android.application.gradle.plugin-8.0.1.pom

and then it fails reporting:

* What went wrong:
Plugin [id: 'com.android.application', version: '8.0.1', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:8.0.1')
  Searched in the following repositories:
    Google
    MavenRepo
    Gradle Central Plugin Repository

I do can access from browser to https://mvnrepository.com/artifact/com.android.application/com.android.application.gradle.plugin/8.0.1 but I have noticed that even though I have no proxy enabled on my Android Studio, maven repository gives 403 if I check connection against it:

enter image description here

enter image description here

Any version of com.android.application would return same error. I'm using gradle 8.1.1, jdk17 and Android Studio Hedgehog | 2023.1.1 Canary 3. Any help?


Solution

  • Solved it. I was having both a gradle installation and an skdman gradle installation. Basic installation had a minor version, while sdkman's was the one I needed. Evidently, there was a conflict between the two. I deleted everything from ~/.gradle dir and only used sdkman's gradle and now it works.