[rn-android] : Handle build tool version for libraries.

Aishwary Raj
Codalyze
Published in
2 min readNov 3, 2017

If you are here after searching,
“Android build fails because it fails to find Build Tools revision 23.0.3" or
“> failed to find Build Tools revision 23.0.2 or xx.x.x”.

issue: console error

This post relates with your issue then you have come to the right place

It is an overhead building for android with react-native if you are using many libraries that interact with native java code. Those libraries need to build with your project too.

There are cases when you can not get it building in the first run because you need to always change the build tool version of the library with yours.
for example:
app/build.gradle contains configuration for build tools

android {
compileSdkVersion 26
buildToolsVersion “26.0.1”

library contains configuration for build tools

android {
compileSdkVersion 23
buildToolsVersion “23.0.1”

this issue usually comes when you start working on a new project and that have many dependent libraries.

To resolve the issue, add the following lines in project/android/build.gradle


subprojects {
afterEvaluate {project ->
if (project.hasProperty(“android”)) {
android {
compileSdkVersion 26
buildToolsVersion “26.0.1”
}
}
}
}

It will build the libraries with buildToolsVersion 26.0.1.

My project/android/build.gradle config. In case you didn’t get it working.

// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
// Add jitpack repository (added by react-native-spinkit)
maven { url "https://jitpack.io" }
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
}
}
}
}

Hope it solves your issue.

--

--

Aishwary Raj
Codalyze

ApplicationDeveloper@Codalyze. #ReactNative #React #JsDev #AWS