找不到com.andorid.tools.build:gradle:3.0.0-beta2

时间:2017-09-20 11:10:09

标签: android gradle android-gradle

我无法解决与gradle文件相关的问题。为了解决这个问题,我已经下载了android studio 3.0 beta 6,其中没有构建项目。在Android studio 2.3.2中出现以下问题

顶级gradle

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta6'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
        maven { url 'https://jitpack.io' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

问题

Error:Could not find com.android.tools.build:gradle:3.0.0-beta2.
Searched in the following locations:
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-beta2/gradle-3.0.0-beta2.pom
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-beta2/gradle-3.0.0-beta2.jar
    https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-beta2/gradle-3.0.0-beta2.pom
    https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-beta2/gradle-3.0.0-beta2.jar
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.0-beta2/gradle-3.0.0-beta2.pom
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.0-beta2/gradle-3.0.0-beta2.jar
Required by:
    project :

修改
刚刚添加了google maven repo:

顶级gradle

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://maven.google.com" }
    }
    dependencies {
//        classpath 'com.android.tools.build:gradle:3.0.0-beta6'

        classpath 'com.android.tools.build:gradle:3.0.0-beta6'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
    }
}

//allprojects {
//    repositories {
//        jcenter()
//        maven { url "https://maven.google.com" }
//        maven { url 'https://jitpack.io' }
//    }
//}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Gradle wrapper

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
#distributionUrl= https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip

enter image description here

修改
在取消注释allproject

之后

错误 enter image description here 如何解决这个问题?我在堆栈上看了很多解决方案,但无法解决这个问题

3 个答案:

答案 0 :(得分:13)

您还必须在顶级 buildscript文件的build.gradle块中添加 maven google

buildscript {
    repositories {
       jcenter()
       ...
       // You need to add the following repository to download the
       // new plugin.
       maven { url "https://maven.google.com" }
    }
   dependencies {
       classpath 'com.android.tools.build:gradle:3.0.0-beta6'
       //...
   }
}

此版本的插件还需要gradle的更新版本。您必须更新distributionUrl中的gradle-wrapper.properties,如下所示:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

有关plugin 3.0.x here的更多信息。

答案 1 :(得分:3)

repositories {
   jcenter()
   ...
   // You need to add the following repository to download the
   // new plugin.
   maven { url "https://maven.google.com" } //THIS
   google() //OR THIS
}

同时删除.gradle和gradle文件夹并重新同步项目。缓存问题

答案 2 :(得分:3)

我使用Android Studio 3.0 Beta2解决了这个问题。我刚刚更改了gradle依赖项,如下所示

顶级gradle依赖

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
        maven { url 'https://jitpack.io' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
  

我刚刚将beta6更改为beta2.I不知道它是如何正常工作但它工作正常