3

I did not touch my project for a week, but when I came back and run the project on the android simulator I suddenly got this error

* What went wrong:
A problem occurred configuring project ':react-native-image-picker'.
> Could not resolve all files for configuration ':react-native-image-picker:classpath'.
> Could not find any matches for com.android.tools.build:gradle:2.2.+ as no versions of com.android.tools.build:gradle are available.
 Searched in the following locations:
     https://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml
     https://jcenter.bintray.com/com/android/tools/build/gradle/
 Required by:
     project :react-native-image-picker

my build.gradle

buildscript {
repositories {
    jcenter()
    google()
    mavenLocal()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    mavenLocal()
    jcenter()
    maven { url "https://jitpack.io" }
    maven { url "https://maven.google.com" }
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
}
}

I have been searching on stackoverflow for a while and I could not find a solution. Any help is appreciated.

stephen
  • 31
  • 1
  • 2
  • You are looking at a wrong gradle file. Look for the one that has `2.2.+`. Maybe look under `app` folder. If you find it, change it to `2.1.2`. I had the same issue today for some reason. – Ziyo Dec 11 '18 at 03:04

4 Answers4

1

Move google() above jcenter() and do this for allProjects section too solved my same problem.

Reza Madani
  • 354
  • 1
  • 5
0

Check out this answer, it should help you solve your problem: https://stackoverflow.com/a/53692168/3104599

Since links aren't enough, i'll copy-paste the answer here. Know that the answer isn't my own, i'm just quoting:

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

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/"  }
        }
    }
} }
Hbibna
  • 568
  • 7
  • 11
0

Check this: https://github.com/react-native-community/react-native-image-picker/issues/999#issuecomment-445465847

I had the same mistake, and I corrected it with this answer.

You just have to edit the 'classpath' of node_modules/react-native-image-picker/android/build.gradle with the same 'classpath' of your android/build.gradle.

I hope it will be useful.

D_Loki
  • 139
  • 1
  • 7
0

Upgrade to the latest version 0.27.2, the problem is fixed there