react-native-image-picker: Build problem: A problem occurred configuring project ':react-native-image-picker'.
Description
I tried to run react-native run-android on a project made by a developer (who I do not have contact anymore), but the build fails with the following output:
FAILURE: Build failed with an exception.
- What went wrong: A problem occurred configuring project ‘:react-native-image-picker’.
Could not resolve all artifacts 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
When i check my android studio graddle build it has the same error:
org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ':react-native-image-picker:classpath'.
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run
at java.lang.Thread.run
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: 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
That is my build.graddle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url "https://jitpack.io" }
jcenter()
}
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.0.2"
}
}
}
afterEvaluate {
project -> if (project.hasProperty("android")) {
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
}
}
}
}
ext {
compileSdkVersion = 26
minSdkVersion = 16
targetSdkVersion = 26
buildToolsVersion = "26.0.2"
googlePlayServicesVersion = "12.0.1"
supportLibVersion = "27.1.0"
}
How to repeat issue and example
react-native run-android
Solution
How to I fix my graddle scripts to match dependencies informations?
Additional Information
- React Native version: 0.55.4
- Platform: Android
- Development Operating System: Windows 10
- Dev tools: Android SDK Tools installed versions are: 27.0.3 and 28.0.3
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 76
- Comments: 81 (4 by maintainers)
Commits related to this issue
- Fix gradle repository (#1002) Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com> — committed to 90dy/react-native-image-picker by 90dy 6 years ago
- Fix gradle repository (#1002) Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com> — committed to 90dy/react-native-image-picker by 90dy 6 years ago
- Fix gradle repository (#1002) Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com> — committed to 90dy/react-native-image-picker by 90dy 6 years ago
- Fix gradle repository (#1002) Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com> — committed to 90dy/react-native-image-picker by 90dy 6 years ago
- Set exact gradle version. See https://github.com/react-native-community/react-native-image-picker/issues/1002 for more info. — committed to mindoktor/react-native-image-picker by deleted user 6 years ago
- Merge pull request #2 from mindoktor/mindoktor/aj/gradle-version-fix Set exact gradle version. See react-native-community#1002 for more info. — committed to mindoktor/react-native-image-picker by deleted user 6 years ago
If you don’t want to wait until this library will release fixed version, here is how you can fix it:
Just add it to your
build.gradleundersubprojectssection in the root (not app/gradle)This Worked for me:
in android/build.gradle add:
changing build.gradle to
fixed the problem for me
Changing build.gradle from: from :
classpath 'com.android.tools.build:gradle:2.2.+'to the more exact:
classpath 'com.android.tools.build:gradle:2.2.3'solves the issue hereAs @maikmacs and @waltershub said.
Using this on you
build.gradlewill solve the issue:Edit: as @evanjmg said, in some cases it will only work if you put it inside
allprojectsin your rootbuild.gradle.What is does: Injects a maven repository into
react-native-image-pickerthat does containscom.android.tools.build:gradle:2.2.+.The good:
react-native-image-picker.The bad:
react-native-image-pickeron your project.I also met the question,
I think this is the perfect solution if you don’t want to upgrade the version,The current version number is ‘0.27.1’.
And,you can use react-native-image-picker@0.27.2,it has been released.
experiencing same issue. Blocked with this whole day. can anyone have a fix?
The same here, started today.
I just change:
to
in node_modules/react-native-vector-icons/android/build.graddle And it’s work for me. It just workaround)
react-native-image-picker@0.27.2has been released, does it work?@kelmants, @Yathousen solution works if you put it in allprojects in your root build.gradle file
I have same issue, started today
Same issue
The same mistake.
react-native-image-picker@0.27.2 has have been released npm i react-native-image-picker@0.27.2 -save
The same issue, it seems https://jcenter.bintray.com/com/android/tools folder was gone or something. What could we do?
@adrispo you should change the library’s build.graddle file, not your project’s!
this work for me, thanks
Yay! this fixed the issue for me. Thank you! 👍 😄
Works for me too!!
Yes. works for me.
Today has just been a bad day for native android dependencies: https://issuetracker.google.com/issues/120759347
I have also been unable to fix the issues with all suggested fixes.
Same Issue, this fixed it for me.
No,it is not working for me
If adding
google()into yourbuild.gradledoesn’t work try adding it at first place in your repositories section ofnode_modules/YOUR_PACKAGE/android/build.gradlefile.It’s fixed now : https://issuetracker.google.com/issues/120759347#comment106 Here what happened
Thanks all for the feedback about the latest release.
It looks like the issue has been solved on local machines, but not in CI environment. That looks like a cache issue to me.
Let’s upgrade Gradle.
worked for me!
It was also not working for us - both locally and on the App Center. Upgrading to
0.27.2fixed local builds, but the App Center ones were still failing. Adding the following tobuild.gradlefixed the App Center builds:This is our current
build.gradlefile:It works! Thanks!!
thank god,i resolved issue by below code:
subprojects { if (project.name.contains('react-native-image-picker')) { buildscript { repositories { jcenter() google() maven { url "https://dl.bintray.com/android/android-tools/" } } } } }thanks guys
Can someone explain what went wrong here? Updating the library simply fixed it for me but I’d like to know what broke and how it caused this error.
@blohamen @KAuthor7112 try adding react-native-vector-icons too
this worked for me
@sginn Same for me after updating to 0.27.2, local build started working but my Bitrise workflow is failing. Cant seem to figure out whats wrong.
@heavyskyl thanks, but the same issue came up for react-native-vector-icons and I solved it doing the same for react-native-vector-icons’s build.graddle. The problem is my node_modules/ folder is in .gitignore and thereby it will propagate to my colleague’s projects.
Is there any contributor there to fix it in the lib’s sources? Thank you very much!