I'm using MPAndroidChart library in android studio. But when I'm trying to sync gradle I get an error as shown in below image.
Gradle text is here to compile MPAndroidChart library.
compile 'com.github.PhilJay:MPAndroidChart:v2.1.4'
How can I resolve this problem?
Add
maven { url "https://jitpack.io" }
to repositories under allprojects not under buildscript see screenshot:
Above solutions did not work for me. I used below to get MPAndroidChart lib working on my project.
Downloaded the latest MPAndroidChart jar from: https://jitpack.io/com/github/PhilJay/MPAndroidChart/v3.0.1/MPAndroidChart-v3.0.1.jar
Copied the downloaded MPAndroidChart-v3.0.1.jar file to YourProject/app/lib directory
Compiled the following dependency at app level build.gradle
dependencies {
compile files('libs/MPAndroidChart-v3.0.1.jar')
}
re-sync the gradle
Go to build.gradle Add the maven { url 'https://jitpack.io' } in both buildscript{}
and allprojects{} as below :
buildscript {
repositories {
maven { url 'https://jitpack.io' }
}
}
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Remember to Sync.
Putting
repositories {
maven { url "https://jitpack.io" }
}
in build.gradle in app folder fixed my issue!
The problem was solved after restarting Android Studio > rebuild project.
I solved this by putting maven { url 'https://jitpack.io' } inside repositories in settings.gradle
In Settings Gradle just add this following code:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
for new android studio version set repository in settings.gradle file
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
// Warning: this repository is going to shut down soon
}
I had the same problem after adding this one in the gradle solved my problem:
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
`
For me the issue was resolved by placing code in below order.
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url "https://maven.google.com" }
}
}
You could encounter this issue if your gradle offline mode is enabled.
turn it off in android studio, Settings > Gradle and uncheck "Offline work" and sync.
I had to move maven { url 'https://jitpack.io' } to be the last declaration after google(), and jcenter().
As the Android studio is updated so you have to control your dependency form your setting.app
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url 'https://jitpack.io' }
}
}
Kindly place this line the respiratory
maven { url 'https://jitpack.io' } //as i have done above
Or just rebuild your project. Worked for me
Build-> Rebuild the project, then re-sync the gradle file.
One Problem can also be, that you are behind a proxy.
So there are two possibilities:
Add your proxy config to android Studio, ore you can also add a gradle.properties file in your project root.
there you have to enter the following credentials:
systemProp.http.proxyPassword=
systemProp.http.proxyHost=
systemProp.http.proxyUser=
systemProp.http.proxyPort=
systemProp.https.proxyPassword=
systemProp.https.proxyHost=
systemProp.https.proxyUser=
systemProp.https.proxyPort=
So the https Properties are pretty necessary. I figured out that often the repositories are available over both protocols. but sometimes only over http or https.
Run gradle wrapper task from command line
cd ~/AndroidStudioProject/myproject/myapp
./gradlew tasks
This worked for me.
If your under proxy add this lines in gradle properties(project properties)
systemProp.http.proxyHost= "Your proxy"
systemProp.http.proxyPort= "Proxy port"
systemProp.https.proxyHost= "Your proxy"
systemProp.https.proxyPort= "Proxy port"
The JitPack repository shouldn't be under buildscripts in this case. It should be just under repositories:
As you can see here on medium or here on the github you have to copy the lib of MPChart AND the Jetpack. There is no reason to fail if you do this.
Don't forgot jetpack.io
Related
I am trying to use MPAndroidChart, but there is occuring build gradle problem.
I reference the github document below.
https://github.com/PhilJay/MPAndroidChart
I follow the 'Gradle Setup'
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
This is how I put the codes
and when I started to build it the error code is
Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'app\build.gradle'
Did I put the build code in the wrong way? or did I missed some important settings?
Probably, you need to append the entry, maven { ... } to the dependencyResolutionManagement.repositories clause in settings.gradle.
app/build.gradle
// repositories {
// maven { url 'https://jitpack.io' }
// }
settings.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
I seems cannot import his github dependencies despite using the right address:
implementation 'com.github.mukeshsolanki:android-otpview-pinview:2.1.2'
When I build, Android Studio cannot find it.
Is there any other alternative? I found chaos pinview but I wanna try his as well.
mvnrepository.com says you can find up to 2.1.0 in the Mulesoft repository. So you need to configure another maven repository in the top-level build.gradle and downgrade the dependency version. Or find another alternative.
You can import the library but for that you need to do the following
maven { url "https://jitpack.io" }
add the above line in settings.gradle like this:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
//add jitpack here
maven { url "https://jitpack.io" }
}
}
rootProject.name = "Example"
include ':app'
I'm forcing gradle to use http
I have modified my gradle-wrapper.properties:
distributionUrl=http\://services.gradle.org/distributions/gradle-4.3-all.zip
The build.gradle:
buildscript {
repositories {
//jcenter()
//google()
maven { url "http://jcenter.bintray.com"}
}
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 {
jcenter()
maven { url 'http://maven.google.com' }
maven { url "http://jitpack.io" }
}}
As far as I'm aware I should use 3.0.1 but when I check the actual repo on jitpack or maven only up to 2.3.3 is available.
The error message I'm getting is:
> Could not resolve all files for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
http://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
http://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :* Try:
Gradle version is 4.3.1 JVM 9.0.1
What can be done to successfully run 'gradle test' here?
EDIT:
uncommenting //google() reveled:
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
When modified the http repo
buildscript {
repositories {
//jcenter()
//google()
maven { url "http://jcenter.bintray.com"}
maven { url "http://maven.google.com"}
}
I got:
> Could not resolve com.android.tools.build:gradle:3.0.1.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.android.tools.build:gradle:3.0.1.
> Could not get resource 'http://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
> Could not GET 'http://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I get the same if I uncomment both jcenter() and google(). Besides, when I check https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/ the link is dead.
Now the jcenter repo https://repo1.maven.org/maven2/com/android/tools/build/gradle/ ends on 2.3.3 version which seems to be correct that this error is happening, the question is what is wrong then?
EDIT- Likely solution the issue happenned because you can't run those excluding https completely, it will fail either way.
Could not resolve com.android.tools.build:gradle:3.0.1.
Read Google's Maven repository
Include Google's Maven repository in your top-level build.gradle file:
FYI
allprojects {
repositories {
google()
// If you're using a version of Gradle lower than 4.1, you must instead use:
// maven {
// url 'https://maven.google.com'
// }
// An alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}
So, According to your version your build.gradle will
buildscript
{
repositories {
jcenter()
google()
maven { url "http://jcenter.bintray.com"}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects
{
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I got the same issue and i solved it by making changes main gradle file, as per suggestion given by android studio
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle-wrapper.properties :
distributionUrl= https\://services.gradle.org/distributions/gradle-4.1-all.zip
my gradle file is like this, make like this in you project it would most probably work.
Thank you.
What worked for me was to remove jcenter() and revert Gradle to an earlier version.
Unfortunately the latest stable version in bintray is 2.3.3 , but atleast I was able to build successfully.
My build.gradle now looks like this:
buildscript {
repositories {
maven { url "http://jcenter.bintray.com"}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "http://jcenter.bintray.com"}
}
}
Try this and make sure your network works well (no proxy ...) :
in gradle-wrapper.properties :
distributionUrl= https\://services.gradle.org/distributions/gradle-4.1-all.zip
and in build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
Add following code into your app level gradle file.
buildscript {
repositories {
mavenCentral()
jcenter()
maven { url "http://jcenter.bintray.com"}
maven { url "http://maven.google.com"}
}
Not sure but your this error Could not resolve all files for configuration ':classpath'. When your path is not set so Follow below step:
Go to the File -> Setting -> Version Controller
Then you Change VCS to < None >
see below image :
I got the same issue because I used to set proxy(no proxy now) and click the OK button in
proxy setting,
so, check the following:
echo $proxy(mac)
/user/XXX/.gradle/gradle.properties
# systemProp.https.proxyPort=1080
# systemProp.http.proxyHost=127.0.0.1
# systemProp.https.proxyHost=127.0.0.1
# systemProp.http.proxyPort=1080
project/gradle.properties
I had the same problem, for solving it I did the following
1- install android studio with required SDKs
2- set manual proxy in android studio: File > Settings > Appearance & Behavior > System Settings > HTTP Proxy
3- In android studio click on Gradle icon, to sync project with gradle files.
Then
4- while android studio and proxy are active, in command prompt by running this command "ionic cordova build android" (I was using ionic platform), it will download all requirement gradle libraries and packages.
Check that you don't filter Google IPs.
This worked for me, I needed to install google dependencies
Another explanation is VPN. When my work's VPN is ON, on my Mac, I get this error. When off, I don't. Could be something particular to my VPN's configuration. So, if you have a VPN running, try disabling it turning the build.
I had problems with the snap version of gradle in my GNU/Linux distribution.
I fixed with:
sudo snap remove gradle
sudo apt install gradle
After migrating from Android Studio 3.0 (Canary 5) to Android Studio 3.0 (Beta 1), and moving to latest gradle , i.e. 'com.android.tools.build:gradle:3.0.0-beta1'
When I try to gradle sync, it error stating below.
Failed to resolve: com.android.support:multidex:1.0.2
Failed to resolve: com.android.support:multidex-instrumentation:1.0.2
I check on Android Studio 3.0 Canary 9 - Failed to resolve packages, it doesn't solve my problem, as I already have this
maven {
url 'https://maven.google.com'
}
I'm surprise it is even asking for multidex 1.0.2, as I only have in my build.gradle
compile 'com.android.support:multidex:1.0.1'
I check using ./gradlew app:dependencies | grep multidex, it shows the failures as below (across various flavors etc)
+--- com.android.support:multidex-instrumentation:1.0.2 FAILED
+--- com.android.support:multidex:1.0.1
+--- com.android.support:multidex:1.0.2 FAILED
+--- com.android.support:multidex:1.0.1 -> 1.0.2 FAILED
Where did the dependencies of multidex:1.0.2 and multidex-instrumentation:1.0.2 comes from? How could I solve this problem?
Apparently my issue is I should post this:
maven {
url 'https://maven.google.com'
}
in allprojects and not in buildscript (the subtle different has blinded me where the issue is), which then looks like this:
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
}
}
Thanks to M D for the pointers!
For me, the solution is move the google() item up to make sure it's before the jcenter(). And actually, I will put the google() in the first place of all the repositories.
Need to add the following as well:
compile 'com.android.support:multidex:1.0.3'
After adding the above line, it worked for me in addition to the above answer
First you need to clean the project , and then rebuild it.
Build ----> Clean Project
Build ----> Rebuild Project
allprojects {
repositories {
google()
}
}
worked for me instead of
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
}
}
if you are in China,
Please use
allprojects {
respositories {
google()
}
}
to instead
allprojects {
respositories {
maven {
url 'https://maven.google.com'
}
}
}
don't ask me why, I don't want to tell you.... may be 'https://maven.google.com' was selected by GFW?
Adding google() in my allprojects solved my issue...
allprojects {
repositories {
jcenter()
google()
}
}
If none of the above solutions are working then add mavenLocal() :
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
mavenLocal()
google()
}
}
Move the google() item up to make sure it's before the jcenter().
repositories {
jcenter()
google()
}
Update all the gradle dependencies to latest version ..
That’s it
my problem was network connection. I needed to connect to a vpn server to connect to jcenter
In my cases, I have no need to requires multidex but I have added due to other dependencies requires[brightcove player]
So I have added below lines in gradle.properties and error was gone.
android.enableJetifier=true
anpVersion=6.18.3
When building, Gradle gave me the Failed to resolve: com.github.PhilJay:MPAndroidChart:v2.2.4 error.
I already added jitpack in build.gradle here:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'aar'
}
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is based here. What am I missing?
Please check if you added below plugin in your build.gradle where you add dependancy of
compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
"apply plugin: 'maven'"
Switch to the latest version:
compile 'com.github.PhilJay:MPAndroidChart:v3.0.0-beta1'
And always use information for the main source - in this case MPAndroidChart Github Repo Readme.MD
If behind a proxy configure your proxy settings in gradle.properties as follows:
systemProp.http.proxyHost=103.7.11.34
systemProp.https.proxyPort=8080
systemProp.https.proxyHost=103.7.11.34
systemProp.http.proxyPort=8080
Note: IP address and port in the lines above to be replaced by your proxy server ip address (or url) and port
Did you add the following in your root build.gradle file: if not then add this.
repositories {
maven { url "https://jitpack.io" }
}
And Restart Android Studio and Rebuild your project.
I have faced same problem the problem was solved after restarting android studio --> rebuild project.
Also if not solved with above you may change the version of distributionUrl in gradle-wrapper.properties to the available newest.