5

Which configuration variables and values should I set where to upgrade to Build Tools 25.0.2? Following the Android Studio messages has not allowed me to fix my Gradle build scripts to Gradle's satisfaction.

Application working fine in Android Studio 2.2 - repeated builds and deployments were fine. Upgraded Android Studio to 2.3, now getting errors The SDK Build Tools revision (21.1.2) is too low for project Minimum required is "25.0.0"

I have followed the prompts in the Messages tab to the build.gradle of each module of the project and added buildToolsVersion '25.0.0' to each as directed, but this has not resolved the issue, and nor has changing to buildToolsVersion '25.0.2'.

I have invalidated the cache and re-synched gradle; invalidated the cache and restarted Android Studio; and invalidated the cache, stopped Android Studio, rm -R'd the various build directories, run a text search for "21." without any hits, and restarted my laptop. No luck.

(please note that this is not the same as https://github.com/c-h-/android_core; in that question Shyamnath Mallinathan is trying to find out how he can carry on using the 23.0.3 version of Build Tools, whereas I am trying to find out how to upgrade to the most recent version of Build Tools - 25.0.2 at the time I raised this)

WillC
  • 957
  • 16
  • 19
  • 1
    Faced similar issues, was able to resolve by pointing to buildtools - 25 Share your gradle files, main and app should do. – Neji Mar 21 '17 at 13:31
  • 1
    also you can use following command to get the dependency graph of your application "gradle dependencies" – Neji Mar 21 '17 at 13:44
  • Thanks @Neji - resolved by 1) setting `buildToolsVersion '25.0.2'` in all modules' `build.gradle` files _and_ 2) adding `compileSdkVersion 25` and `buildToolsVersion '25.0.2'` to the top-level `build.gradle` - which didn't include it before. Feels like there was a change to how gradle propagated/resolved the Build Tools version within a project. – WillC Mar 21 '17 at 15:20

1 Answers1

1

Thanks to @Neji :- I resolved this by

1) running "gradle dependencies" to get the dependency graph of my application

2) setting buildToolsVersion '25.0.2' in all modules' build.gradle files and

3) adding compileSdkVersion 25 and buildToolsVersion '25.0.2' to the top-level build.gradle

WillC
  • 957
  • 16
  • 19
  • 1
    `android` block is not supposed to be in root build.gradle if you're using separate modules. – Eugen Pechanec Apr 07 '17 at 07:24
  • Is it not? Thanks - although I'm surprised: I thought that it was there to set the application-wide defaults that could then overridden by each module. My problems make more sense in that case, but I would have expected a Gradle error pointing that out to me. I started my project as a fork of https://github.com/c-h-/android_core, which does have `android` clauses in the top-level `build.gradle`, and no problems until this most recent upgrade. – WillC Apr 07 '17 at 07:27
  • 1
    Ooooh crap, you're using the `allprojects` block? Wait, `android` block is only available after applying `com.android.application` or `...library` plugin which you should only do in modules. – Eugen Pechanec Apr 07 '17 at 07:29
  • yep - I am using 'allprojects' . Where's a good place to learn all these if-then-except-otherwise rules for Gradle? – WillC Apr 07 '17 at 07:32
  • Thanks Eugen; https://github.com/c-h-/android_core is from a few years ago, and I get the feeling it is still focused on getting ROS-Java to work, rather than good Android/Gradle practices. – WillC Apr 07 '17 at 07:48
  • You just pick these up as you go, you can get useful stuff altogether by following Jake Wharton or Genymotion on Twitter, google "speed gradle build" and follow the tips. I read somewhere to avoid `allprojects` because it disables parallel builds which in turn build decoupled modules faster. I forgot `allprojects` existed :D – Eugen Pechanec Apr 07 '17 at 07:52
  • Oh that's just nasty. per my comment at http://stackoverflow.com/a/35708264/1200764 I really miss Ant's visibility, even though I love the dependency injection with Maven/Gradle. – WillC Apr 07 '17 at 07:58