Gradle项目同步失败-Android Studio-无法找到构建工具版本27.1.0

时间:2018-07-18 02:10:46

标签: android gradle

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.android.sqliteapp"
        minSdkVersion 23
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
        }
    }
    buildToolsVersion '27.1.0'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso- core:3.0.2'
}

发生错误

失败:构建失败,并出现异常。

  • 出了什么问题: 配置项目':app'时发生问题。

      

    找不到构建工具版本27.1.0

  • 尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获取完整的见解。

  • https://help.gradle.org

  • 获得更多帮助

2秒内配置失败 找不到构建工具版本27.1.0

build.gradle

buildscript {

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

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

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

1 个答案:

答案 0 :(得分:0)

将此代码放入您的build.gradle(应用级别)

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

    }

}

相关问题