使用较低的SDK构建工具版本进行编译

时间:2019-03-31 12:20:28

标签: android gradle android-gradle

尝试使用较低的SDK版本构建项目。得到警告:

body 
.navbar {
  overflow: hidden;
  background-color: #221a57;
}

.navbar a {
  float: left;
  font-size: 16px;
  color: white;
  text-align: center;
  min-width: 160px;
  padding: 14px 16px;
  text-decoration: none;
}

.dropdown {
  float: left;
  overflow: hidden;
}

.dropdown .dropbtn {
  font-size: 16px;  
  border: none;
  outline: none;
  color: white;
  min-width: 192px;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}

.navbar a:hover, .dropdown:hover .dropbtn {
  background-color: #F73D4B;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #DDDDDD;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

.dropdown-content a:hover {
  background-color: #ddd;
}

.dropdown:hover .dropdown-content {
  display: block;
}

我应该以某种方式安装较低的Gradle插件版本吗?我该怎么做?

4 个答案:

答案 0 :(得分:3)

您可以在项目的build.gradle文件中更改Androd gradle插件版本

buildscript {
    ext.kotlin_version = '1.3.21'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

您可以查看Android Gradle plugin release notes

答案 1 :(得分:2)

您可以忽略此警告,因为android studio正在使用正确的构建工具版本“ Android SDK Build Tools 28.0.3”。

您还可以修改您的app / build.gradle。

defaultConfig {

    buildToolsVersion = 28.0.3

}

答案 2 :(得分:2)

只需从模块的build.gradle中删除这一行,即可消除警告消息:

buildToolsVersion "25.0.1"

然后将使用与targetSdkVersion相匹配的最新版本。绝对不再需要手动设置buildToolsVersion-降级Gradle插件也是没有意义的,因为您需要降级整个IDE才能拥有匹配的版本。

答案 3 :(得分:-1)

Firstly, this is just a warning and you can ignore it. 
This warning will not create any problem for basic development.

Secondly, this warning appears when somehow your build.gradle is using 25.0.1 as build tools version, which in turn can be from any library/package that you have used and might not be from any of your build.gradle files

In order to remove this warning completely, you need to make sure that all your module level build.gradle files contains the following lines :

    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    targetSdkVersion 28

Or, you can lower the gradle version in your project level build.gradle file (The reference you posted in  your question) with this line

dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
}

Hope it helps you :)