Android gradle: buildtoolsVersion vs compileSdkVersion
Asked Answered
K

2

191

What's the difference between buildtoolsVersion vs compileSdkVersion in the build.gradle for an Android project?

EDIT: Specifically, I'd like clarification on what the build tool is?

Keloid answered 2/7, 2014 at 0:8 Comment(1)
Is this what you're looking for: developer.android.com/tools/revisions/build-tools.htmlLenticular
R
236

compileSdkVersion is the API version of Android that you compile against.

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.

At IO 2014, we release API 20 and build-tools 20.0.0 to go with it.

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.

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.

Romany answered 2/7, 2014 at 4:53 Comment(8)
Is it possible to use a higher buildToolsVersion on a lower compileSdkVersion, say 20.0.0 buildToolsVersion on a 18.0.0 compileSdkVersion?Keloid
@Keloid yes, build tools will support older versions.Romany
@XavierDucrohet Do I have to specify buildToolsVersion? I remember that I read somewhere that the latest build tools version is selected automatically. I tried removing buildToolsVersion, but Android Studio is not happy with it.Hawser
@Hawser Only Eclipse and Ant would use the latest version so that older projects would keep working. Gradle (and Studio) requires you put a version).Romany
Anyone with a link do a document on what is actually going on behind the scenes with compileSdkVersion, buildToolsVersion, minSdkVersion and targetSdkVersion? Id like to properly understand it.Uvula
@Uvula See this valuable post by Ian Lake:- medium.com/google-developers/…Isodynamic
@Hawser If you don't specify buildToolsVersion, Android Studio will show Error:Cause: buildToolsVersion is not specified.Arad
@MarkLu As of Android plugin for Grade v3.0.0, you no longer have to specify buildToolsVersion in the build.gradle fileEldoraeldorado
S
61

Android Studio 3.0 update

It is no longer as important to know the exact buildToolsVersion as it used to be because it is now chosen automatically.

The documentation says:

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.

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 Tools from the list and check Show Package Details. The last item will show the most recent version.

enter image description here

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.

Secluded answered 31/8, 2016 at 1:5 Comment(2)
Just to be clear, in AS 3.2 the path to the above is "File=>Settings=>Appearance & Behavor ...."Referendum
Its very strange, my release build fails when not defining build tools version (AGP 4.1.1), complaining about build tools version too lowPilewort

© 2022 - 2024 — McMap. All rights reserved.