1. 程式人生 > >Error:Cause: buildToolsVersion is not specified.

Error:Cause: buildToolsVersion is not specified.

同事扔給我一個專案,剛開始報錯

Error:(6, 0) Gradle DSL method not found: 'google()'
Possible causes:<ul><li>The project 'CarJniDemo' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
<a href="fixGradleElements">Upgrade plugin to
version 2.3.3 and sync project</a></li><li>The project 'CarJniDemo' may be using a version of Gradle that does not contain the method. <a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin. <a href="apply.gradle.plugin"
>Apply Gradle plugin</a></li>

將下面程式碼

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

改為

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

問題接踵而來

Error:Cause: buildToolsVersion is not specified.

build.gradle中沒有buildToolsVersion

buildToolsVersion "26.0.2"

問題解決