How to permanently fix “SDK Build Tools is too low for project” error in React Native for Android

Or: How not to have your react-native Android project completely messed up every time you add a dependency with yarn


One of the most annoying things that can happen while developing a React Native app is the dreaded A problem occurred configuring project ‘:app’ error, immediately followed by a more specific The SDK Build Tools revision (xx.x.x) is too low for project ‘:your-react-native-dependency’ message.

This may occur in a variety of different situations:

  • You ran react-native run-android after having updated a specific native dependency;
  • You ran the same command after having simply run yarn, which internally removes every manual update you may have done to the files in the node_modules folder (besides actually updating every dep);
  • You tried to link a native module without success (either with react-native link your-react-native-dependency or manually);

Probably you already know how to fix this manually, but chances are you’re looking for a way to automatize it, not to waste precious minutes every day.

Well, after this article you’ll know how to deal with it, for good.

One of the most annoying things that can happen while developing a React Native app is the dreaded A problem occurred configuring project ‘:app’ error, immediately followed by a more specific The SDK Build Tools revision (xx.x.x) is too low for project ‘:your-react-native-dependency’ message.

Manual solution

Honestly, I have no intention to waste your time digging into the manual solution, since there are many other tutorials online that do it pretty well (example), but all of them — at least, everyone of them I’ve managed to find — only offer a temporary solution, which you have to repeat every time you perform one of the steps above, or even worse, propose you to downgrade to an old (and slow) version of gradle, how useful can that be?

So, let’s delve into the real solution.

Automatic solution

What’s better than a simple script to change all the compileSdkVersion and buildToolsVersion entries in every react-native’s Android dependency of our project? We could write it in JavaScript and then hook it up to the scripts section of our package.json, and then invoke it from npm run or yarn run.

Well… While that could certainly be a huge step forward, we’d still have to parse the gradle files and edit them without invalidating their sintax. Nope, to solve this issue correctly and in a clean manner, we should leverage the Gradle build tool scripting language directly.

Gradle’s Project API has a method called afterEvaluate whose description is the following:

void afterEvaluate(Closure closure)
Adds a closure to be called immediately after this project has been evaluated. The project is passed to the closure as a parameter. Such a listener gets notified when the build file belonging to this project has been executed. A parent project may for example add such a listener to its child project. Such a listener can further configure those child projects based on the state of the child projects after their build files have been run.

You can basically think of it as React’s componentDidMount on steroids.

The right place to call this method is in your yourReactNativeProject/android/build.gradle file, inside the subprojects {} section.

Your build.gradle file should look like the following:

Now, let’s add the subprojects {} section and invoke our script:

What did we just write? We basically delegated to Gradle the task of overwriting two particular entries of the ‘android’ property of every dep’s build.gradle file: ‘compileSdkVersion’ and ‘buildToolsVersion’.

(I know, all these files have the same name and extension, it can be quite confusing for newbies).

You should obtain the following result (more or less) for every native dependency of your React Native Android project.

That’s it, simple as pie. I personally love when a tedious issue can be fixed in a handful of lines of code.


You may also be interested in: React Native on XCode Beta 8.0: how to fix initial build error.

Some of my open source libraries I’d love to hear feedback about:

If you liked this tutorial and want to keep learning about React Native tips and tricks, make sure to click the “Follow” button below, and follow me on Github at @jkomyno