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


#1

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

#2

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


#3

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.+


#4

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


#5

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


How to fix the android environment setting issues?
#6

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'
    }
}

#7

Thanks, work for me.


#8

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


#9

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


#10

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.