簡體   English   中英

找不到com.android.tools.build:gradle:3.0.1

[英]Could not find com.android.tools.build:gradle:3.0.1

當我嘗試使用gradle包裝器構建我的項目時,我收到此錯誤:

./gradlew

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all files for configuration ':app:classpath'.
   > Could not find com.android.tools.build:gradle:3.0.1.
     Searched in the following locations:
         https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
         https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
     Required by:
         project :app

* 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

同一個項目在Android Studio中構建正常。

我已經檢查了這個這個,但我使用gradle包裝器版本4.1,添加了google()存儲庫,甚至嘗試設置android.enableAapt2=false 還有其他提示嗎? 謝謝。

我的root build.gradle文件:

 // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

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

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

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

我的gradle-wrapper.properties文件:

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

更新:加布里埃爾是對的。 我還要在app/build.gradle file添加存儲庫:

...
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}
...

我想我很困惑這個stament“要添加這些圖書館之一到您的構建,包括頂層的build.gradle文件谷歌的Maven倉庫”這里

只是想留下額外的小費。 當我安裝Android Studio時,我在某處讀到了建議保留此配置(帶有'+'符號)

build.gradle(項目)

dependencies {
        classpath 'com.android.tools.build:gradle:+'
        .....
        #more lines here
}

但是,我使用的項目使用舊版本的gradle,此行始終請求最新版本。 我花了一段時間來搞清楚。

檢查Android Studio上的代理設置

文件>設置>外觀

行為>系統設置> HTTP代理

以下是我如何解決這個問題。 更改root build.gradle文件:

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

    .....
        //other codes here
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM