Build fails on Android - could not resolve all files for configuration

Hello guys,
I’m getting a build error when running the command ionic cordova run android --device. The error tells that a gradle resource could not be loaded, but I am able to get this resource in the browser on the same machine. I’m working behind a proxy. I set the proxy in the gradle.properties file in my gradle home directory. Below is the console output.

ANDROID_HOME=C:\Users\dsimon\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144
studio
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:3.0.0.

     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:3.0.0.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
               > [PROXY_HOST]
      > Could not resolve com.android.tools.build:gradle:3.0.0.
         > Could not get resource 'https://maven.google.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
            > Could not GET 'https://maven.google.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
               > [PROXY_HOST]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
(node:25532) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:3.0.0.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:3.0.0.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
               > [PROXY_HOST]
      > Could not resolve com.android.tools.build:gradle:3.0.0.
         > Could not get resource 'https://maven.google.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
            > Could not GET 'https://maven.google.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
               > [PROXY_HOST]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

[OK] Your app has been deployed.
     Did you know you can live-reload changes from your app with --livereload?

And the output of ionic info:

cli packages: (C:\Users\dsimon\AppData\Roaming\npm\node_modules)

    @ionic/cli-plugin-proxy : 1.5.7
    @ionic/cli-utils        : 1.19.1
    ionic (Ionic CLI)       : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.6
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.9.4
    npm               : 5.6.0
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME     : C:\Users\dsimon\AppData\Local\Android\Sdk
    HTTP_PROXY       : [PROXY_HOST]:3128
    http_proxy       : [PROXY_HOST]:3128
    HTTPS_PROXY      : [PROXY_HOST]:3128
    https_proxy      : [PROXY_HOST]:3128
    IONIC_HTTP_PROXY : [PROXY_HOST]:3128
    PROXY            : [PROXY_HOST]:3128
    proxy            : [PROXY_HOST]:3128

Misc:

    backend : legacy

Please tells me if it works:

  • modify:
    mavenCentral()
    jcenter()

  • to:
    maven { url "https://maven.google.com" }
    jcenter { url "http://jcenter.bintray.com/"}

  • in files:
    platforms/android/build.gradle
    platforms/android/app/build.gradle
    platforms/android/CordovaLib/build.gradle

22 Likes

It does not work. I get an error on :app:preDebugBuild
Could not resolve all files for configuration ‘:app:debugCompileClasspath’
Could not find any version that matches com.google.android.gms:play-services-measurement-base:12.+

Hi, did you find a solution to this issue … ?

Yes. If my memory serves me correctly, I just deleted the directory, cloned it again and added android platform and everything worked fine.

1 Like

I have same problem.
I’ve added google() to all of my buildscripts and nothing solved!

buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}
4 Likes

Thanks, work for me.

this solution worked for me. Thanks @ekoz for sharing this trick.

Finally, Works for me!
I’ve spent too much time to for this…
thanks!

This solution is not working, got this log:

BUILD FAILED in 6s
cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:3.0.1.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:3.0.1.
         > Could not get resource 'https://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
            > Could not GET 'https://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
               > Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
      > Could not resolve com.android.tools.build:gradle:3.0.1.
         > Could not get resource 'http://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
            > Could not GET 'http://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
               > Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
[ERROR] An error occurred while running subprocess cordova.

Thanks @ekoz it works.

Remove /platforms/andorid folder and re-run:

$ ionic cordova platform add android

Work for me!

5 Likes

Worked for me also. Cheers

This work for me. Good solution…Thanks :blush:

It was because of IP sanctions! using vpn connection errors got away!

2 Likes

Worked for me as well! Any idea what caused this issue?

Having the same error for a while now, none of the solutions above actually helped me.
Somebody got another solution, or even the cause of it?

It worked for me as well!
Thanks :wink:

it finallyyyyyyy works,
spent several days fixing issue on the console,
your solution helped me through the last pain TwT
Thank you so much ~

Thanks for this. This worked for me.