如何在Android Studio 3.0.1中更改构建工具版本?

use*_*308 16 configuration build-tools android-studio

我刚刚将我的Android工作室从2.3升级到3.0.1.但我收到此错误消息(我已经安装了API 27)并且不知道如何修复它,因为我在新版本的android studio中找不到构建工具版本!

Error:Failed to find Build Tools revision 26.0.2 <a href="install.build.tools">Install Build Tools 26.0.2 and sync project</a>
Run Code Online (Sandbox Code Playgroud)

gradle文件已更改,项目结构也只有一个选项卡!

编辑:这是`app/build.gradle的内容:

apply plugin: 'com.android.application'

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Run Code Online (Sandbox Code Playgroud)

如你所见,其中没有buildToolsVersion.那么,当我的计算机上安装了27版本时,为什么我的android工作室会查找这个特定版本(26)?另外,我在哪里可以看到buildToolsVersion "26.0.2" and change it tobuildToolsVersion"27.0.3"?

sha*_*erg 22

您的项目正在寻找Build Tools版本26.0.2,但您尚未下载并在计算机上安装它.

要下载它,请转到工具> Android> SDK管理器,然后单击新窗口顶部的"SDK工具"选项卡.然后选择右下角的"显示包详细信息"复选框.最后,向下滚动到您看到的位置26.0.2,选中它旁边的复选框,然后单击"确定"开始安装过程.

如果要更改项目中的Build Tools版本,请在项目的build.gradle文件中指定(在"app"模块中).打开文件,通过添加/更新"android"部分中的以下属性来添加或更新要使用的Build Tools版本:

android {
    buildToolsVersion "27.0.3"
    ...
}
Run Code Online (Sandbox Code Playgroud)

  • @karl 这是一个很好的问题...根据 https://developer.android.com/studio/releases/build-tools,“如果您使用 Gradle 3.0.0 或更高版本的 Android 插件,您的项目会自动使用插件指定的构建工具的默认版本。” 默认情况下,插件使用您正在使用的插件版本所需的最低版本的构建工具。 (3认同)