Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native Android - Could not find com.android.tools:common

It seems that somehow the android/tools/common library has been deleted (pom, jar).

This caused many react native libraries that are using an old gradle version in their classpath (e.g com.android.tools.build:gradle:2.2.3) to not being able to sync

How can i fix it?

like image 795
Elad Gelman Avatar asked Dec 09 '18 10:12

Elad Gelman


2 Answers

Update, I had to add more code to build.gradle

This is my fix, I did not fork repos just used this workaround: add this to your build.gradle file, the sibling of settings.gradle file

buildscript {
  repositories {
     google()
     jcenter { url "http://jcenter.bintray.com/"}
     maven { url "https://dl.bintray.com/android/android-tools" }
  }
}

subprojects { project ->
  def name = project.name
  if (name.contains('module name, e.g. react-native-blur')
        || name.contains('other module name, e.g. react-native-image-picker')) {
    buildscript {
        repositories {
            maven { url "https://dl.bintray.com/android/android-tools/"  }
        }
    }
  } 
}
like image 198
Elad Gelman Avatar answered Nov 12 '22 20:11

Elad Gelman


In my build.gradle file (of the project not the app) i've added the new bintray url first but also had to add all the others after:

subprojects {
    buildscript {
        repositories {
            maven { url 'https://dl.bintray.com/android/android-tools' }
            google()
            mavenLocal()
            jcenter()
        }
    }
}
like image 40
Boaz Saragossi Avatar answered Nov 12 '22 22:11

Boaz Saragossi