Could not find com.android.tools.build:gradle:3.0.

2019-04-03 20:57发布

This question already has an answer here:

When I try to build may Android project from command line, I get following error messages:

A problem occurred configuring project ':mylib'. Could not resolve all files for configuration ':mylib:classpath'. Could not find com.android.tools.build:gradle:3.0.0. Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar Required by: project :mylib

And when I try to access for example the address "https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom" directly via browser, following is shown:

{
  "errors" : [ {
    "status" : 404,
    "message" : "Could not find resource"
  } ]
}

The root gradle file contains following code:

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

  // NOTE: Do not place your application dependencies here; they belong
  // in the individual module build.gradle files
}

...

allprojects {
  repositories {
    jcenter()
    google()
  }
}

And the file gradle-wrapper.properties contains following values:

#Fri Oct 27 10:09:16 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

The same configuration works fine if I compile from Android Studio 3.0. But if I try to compile directly from the command line, I receive the error.

Could anybody help me?

2条回答
可以哭但决不认输i
2楼-- · 2019-04-03 21:23

My question is "./gradlew assembleDebug" appeared,Android studio build is successful。I solved it this way

repositories {
    jcenter()
    google()
}

or

repositories {
    jcenter()
    maven {
        url 'https://maven.google.com'
    }
}
查看更多
我想做一个坏孩纸
3楼-- · 2019-04-03 21:41

I am not quite sure, but maybe you should try putting the repositories tag at the same level of the dependencies tag. So:

buildscript {
    repositories {
        ...
    }
    dependencies {
        ...
    }
}
查看更多
登录 后发表回答