Android gradle:buildtoolsVersion 与 compileSdkVersion
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24521017/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android gradle: buildtoolsVersion vs compileSdkVersion
提问by Glide
What's the difference between buildtoolsVersion
vs compileSdkVersion
in the build.gradle for an Android project?
Android 项目的 build.gradle 中的buildtoolsVersion
vs 有什么区别compileSdkVersion
?
EDIT: Specifically, I'd like clarification on what the build tool is?
编辑:具体来说,我想澄清一下构建工具是什么?
回答by Xavier Ducrohet
compileSdkVersion
is the API version of Android that you compile against.
compileSdkVersion
是您编译所针对的 Android 的 API 版本。
buildToolsVersion
is the version of the compilers (aapt, dx, renderscript compiler, etc...) that you want to use. For each API level (starting with 18), there is a matching .0.0 version.
buildToolsVersion
是您要使用的编译器(aapt、dx、renderscript 编译器等)的版本。对于每个 API 级别(从 18 开始),都有一个匹配的 .0.0 版本。
At IO 2014, we release API 20 and build-tools 20.0.0 to go with it.
在 IO 2014 上,我们发布了 API 20 和 build-tools 20.0.0 以配合它。
Between Android releases we will release updates of the compilers, and so we'll release version .0.1, .0.2, etc... Because we don't want to silently update these version under you, it's up to you to move to the new version when it's convenient for you.
在 Android 版本之间,我们将发布编译器的更新,因此我们将发布 .0.1、.0.2 等版本...在您方便时使用新版本。
You can use a higher version of the build-tools than your compileSdkVersion, in order to pick up new/better compiler while not changing what you build your app against.
您可以使用比 compileSdkVersion 更高版本的构建工具,以便在不更改构建应用程序的基础上选择新的/更好的编译器。
回答by Suragch
Android Studio 3.0 update
Android Studio 3.0 更新
It is no longer as important to know the exact buildToolsVersion
as it used to be because it is now chosen automatically.
知道确切信息不再像buildToolsVersion
过去那样重要,因为现在它是自动选择的。
The documentationsays:
该文件说:
You no longer need to specify a version for the build tools (so, you can now remove the
android.buildToolsVersion
property). By default, the plugin automatically uses the minimum required build tools version for the version of Android plugin you're using.
您不再需要为构建工具指定版本(因此,您现在可以删除该
android.buildToolsVersion
属性)。默认情况下,该插件会自动使用您正在使用的 Android 插件版本所需的最低构建工具版本。
Finding the exact version number
查找确切的版本号
I originally came here looking for how to know the exact version number of the most recent Build Tools Version (back in the days when this needed to be updated manually). If you still need to do this, you can find it in the following way:
我最初来到这里是为了寻找如何知道最新构建工具版本的确切版本号(回到需要手动更新的时代)。如果您还需要这样做,您可以通过以下方式找到它:
Go to Tools > SDK Manager > SDK Tools (tab). Select Android SDK Build Toolsfrom the list and check Show Package Details. The last item will show the most recent version.
转到工具 > SDK 管理器 > SDK 工具(选项卡)。从列表中选择Android SDK Build Tools并选中Show Package Details。最后一项将显示最新版本。
In the image above, I can see that I have buildToolsVersion 27.0.3
installed. There is a more recent rc
(release candidate) version, but I haven't installed it. I will when the stable version comes out.
在上图中,我可以看到我已经buildToolsVersion 27.0.3
安装。有一个更新的rc
(候选发布)版本,但我还没有安装它。等稳定版出来了。