I am trying to add an external dependency from jcenter
compile 'com.droidninja:filepicker:2.0.4'
but I keep getting these errors and I can't figure out what is going wrong.
I have seen the same errors come up in lot of projects but nobody seems to know whats going wrong.
The problem is not with the dependency you just added but the Android Support library's dependencies. The latest SDK updates move towards using the remote Google Maven repository instead of downloading everything to be available locally. In order to fix dependency resolution problems follow the Adding Support Libraries guide. Really briefly this is what you have to do:
Open your project's build.gradle (note that this is not the module's file!)
Add the Google Maven repo to the project repositories:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
It's also recommended to add the repo to the buildscript block too, so later on the Gradle plugins can be downloaded from there too:
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
Related
I Got this error after installing Android Studio
A problem occurred configuring root project 'afsar'.
> Could not resolve all files for configuration ':classpath'.
> Could not find bundletool-1.11.0.jar (com.android.tools.build:bundletool:1.11.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/1.11.0/bundletool-1.11.0.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
I added these lines to gradle but not work:
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
jcenter()
Finally I downloaded bundletool-1.11.0.jar file but I don't know where to paste it. please help!
Answer:
I selected the latest version of gradle for my app and my problem was solved!!!
gradle-version: 8.0-rc-2
Android-gradle-plugin-version: 7.4.0-beta04
First, you shouldn't HAVE to download dependencies manually. Usually, when Gradle can't find an existing artifact from a well-known repo, it's just a sign that you have some network issue going on (i.e., proxies, firewall, other network security). If you can point a web-browser to https://www.gradle.org, you should be able to have Gradle do the downloading for you if you sort out the real problem.
Some things that might help are replacing jcenter() (now non-existent--see here: "JCenter is at end of life" android lint warning, what is the replacement? ) with something like mavenCentral(), and perhaps the maven.google.com with its shortcut, google().
Then, check your proxy settings in gradle.properties (perhaps with the answers here: Gradle proxy configuration ).
But, if you do have an artifact in hand, and you just want to use it, you can use the flatDir inside of repositories { ... }, such as described here:
https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
Gradle build using plugins and dependencies from "flatDir"
flatDir uses a path specified as a "repository". Together, it might look like:
repositories {
google(); mavenCentral()
maven { url 'https://maven.fabric.io/public' }
flatDir {
dirs "${projectDir}/libs"
}
}
This will look in multiple existing repositories, as well as search the folder libs/ in your project for the local copy of the .jar.
I am working on a project where I have used com.github.JesusM:HoloCircleSeekBar:v2.2.2 library. When I tried to make the build in my system, it worked without any issue but when I tried to run the same project in other system it got the issue that the library can't be resolved. What could be the reason?
you can read the instruction in the Github page of the library
add this line in the build.gradle repositories in project level
maven {url "https://jitpack.io"}
like this
allprojects {
repositories {
google()
jcenter()
maven {url "https://jitpack.io"}
}
}
also, you can download the source code and add to your project as a module(the library not updated for 4 years so a lot of changes happens) and change dependencies and codes to work properly
suddenly gradle is unable to build the same code that was working moments ago !
my project depends on google play service dependencies
it says :
Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:15.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services-basement/15.0.1/play-services-basement-15.0.1.aar
I think the aar file was removed from google by mistake
Does anyone have any idea, what is going on?
Add google() repository in your build.gradle. And check that google() is before jcenter().
The problem seems to be with jcenter. I have spent hours together with this problem and your problem seems to be similar to mine and I think the following solution should work.
For some reason and for many libraries in jcenter, the pom files of many libraries are kept in place but corresponding aar files have been removed. This is also the case with play-services-basement library. Check the following here for reference ( pom file of play-services-basement is available at jcentre here but aar file is not available at jcentre here):
Solution :
In your project level gradle file , change the following block of code
allprojects {
repositories {
jcenter()
google()
}
}
to
allprojects {
repositories {
google()
jcenter()
}
}
why this works ?
In our first code block, when gradle tries to resolve a dependency in the repository(in my case,it was google-services-basement in jcentre repository), it ddi not get resolved as corresponding aar files has been removed. As a result , build fails with something like :
Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:15.0.1).
In our second code block, google repository has been referenced before jcenter repository. When gradle build starts, it looks first in the libraries listed first in repositories{... for resolving any library that is used in the project. Now, when gradle tries to resolve play-services-basement in jcenter, it is successful in resolving dependency as corresponding aar file has been made available by google repository(the same aar file of latest version is not available in jcenter repository) which has been referenced before jcenter repository is assessed. Do check and let me know if that works.
IN Worked
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url 'https://maven.google.com'
}
}
suddenly gradle is unable to build the same code that was working moments ago !
my project depends on google play service dependencies
it says :
Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:15.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services-basement/15.0.1/play-services-basement-15.0.1.aar
I think the aar file was removed from google by mistake
Does anyone have any idea, what is going on?
Add google() repository in your build.gradle. And check that google() is before jcenter().
The problem seems to be with jcenter. I have spent hours together with this problem and your problem seems to be similar to mine and I think the following solution should work.
For some reason and for many libraries in jcenter, the pom files of many libraries are kept in place but corresponding aar files have been removed. This is also the case with play-services-basement library. Check the following here for reference ( pom file of play-services-basement is available at jcentre here but aar file is not available at jcentre here):
Solution :
In your project level gradle file , change the following block of code
allprojects {
repositories {
jcenter()
google()
}
}
to
allprojects {
repositories {
google()
jcenter()
}
}
why this works ?
In our first code block, when gradle tries to resolve a dependency in the repository(in my case,it was google-services-basement in jcentre repository), it ddi not get resolved as corresponding aar files has been removed. As a result , build fails with something like :
Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:15.0.1).
In our second code block, google repository has been referenced before jcenter repository. When gradle build starts, it looks first in the libraries listed first in repositories{... for resolving any library that is used in the project. Now, when gradle tries to resolve play-services-basement in jcenter, it is successful in resolving dependency as corresponding aar file has been made available by google repository(the same aar file of latest version is not available in jcenter repository) which has been referenced before jcenter repository is assessed. Do check and let me know if that works.
IN Worked
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url 'https://maven.google.com'
}
}
i have a bigger Ionic3 project running and did not do any changes since i had a successful build last time. Today, i tried to build again, getting the error:
Could not find play-services-auth-base.aar (com.google.android.gms:play-services-auth-base:15.0.1).
I can not figure out why this happens. Cordova-platform is Version 6.3.0.
Steps done so far:
Installed cordova-android-play-services-gradle-release, which 15.+ as version during the build
Installed cordova-android-support-gradle-release, which 27.+ as version during the build
Manipulated gradle.build within the platform, as recommended in other stackoverflow-questions.
Maybe updating cordova to 7.x also is an option, but i want to avoid it due to multiple cordova plugin dependencies.
Code:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
There is currently something wrong with the jcenter() repository. I guess they will fix that soon.
Anyway, for the most packages a fix could be to add the google() repository at the first position in the build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
}
allprojects {
repositories {
google()
maven {
url "https://maven.google.com"
}
jcenter()
}
It's important that google() is listed before jcenter().
If your app does not require any of the newer Google APIs, try specifying an older Play Services Version in your config.xml file. I got a successful build by using 11.6.2. Anything newer gave me the same build error.
According to this: https://developer.android.com/topic/libraries/support-library/setup
if you're using a version of Gradle lower than 4.1, you must use
maven { url 'maven.google.com'; }
instead of
google()
As far as I can see, this error may also occur, when Google or anyone else marks the repository "google-cache" as "blacked-out". Then instead of getting the library you want, you'll get a json string representig that error. It seems that this is enough information for Android Studio to say "OK, found a library entry, but its not there", so the build will fail. google() or maven() should then provide a backup entry, but because jcenter() was the first repository in the list and has given a "proper answer" of the request gradle won't ask the other repos for a solution.
As #Manuel already posted, just put the google() repo before jcenter() in your projects build.gradle.