Gradle Build Error: Unable to load Maven meta-data from https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml
Asked Answered
T

7

21

I am getting a gradle build error in Android studio as below:

    Error:A problem occurred configuring project ':MyApp'.
    Could not resolve all dependencies for configuration ':MyApp:classpath'.
    Could not resolve io.fabric.tools:gradle:1.+.     
Required by:
    sw-android:MyApp:unspecified
    Failed to list versions for io.fabric.tools:gradle.
        Unable to load Maven meta-data from     
    https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml.
     Could not GET 'https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml'.
    peer not authenticated
        Failed to list versions for io.fabric.tools:gradle.
        Unable to load Maven meta-data from  
        http://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml.
        Could not GET http://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml'.
        peer not authenticated

I found that "https" Tag is not working to download the Maven URL so I changed the https to http in my build.gradle file. Also I checked all the gradle settings and manually modify the other.xml file in the path C:\Users\Ashfaque1.AndroidStudio\config\options\ but still it is taking the https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml. Also once I am hitting this link to the browser I am getting the 404 exception but the 2nd URL in Error http://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml, I am able to hit successfully and downloading the Metadata file correctly in my system. Not able to understand what is the problem, where I need to change the settings so that metadata file will be downloaded. Please suggest if I need to change any settings or from where it is taking this URL https://repo1.maven.org/maven2//io/fabric/tools/gradle/maven-metadata.xml

My build.gradle file is as below:

    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'

    buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
        classpath 'io.fabric.tools:gradle:1.+'
    }
    }

    repositories {
        mavenCentral()
        maven { url 'http://maven.fabric.io/public' }
    }

    dependencies {
    compile 'com.android.support:multidex:1.0.0'
    compile fileTree(dir: 'libs',include: '*.jar')
    compile project(':DeviceService')
    compile project(':RatioCommon')
    compile project(':SlidingMenu:library')   
    compile project(':SmartViewLibrary:SmartView')
    compile project(':SmartViewLibrary:OpenAccess')
    compile('com.crashlytics.sdk.android:crashlytics:2.2.0@aar') {
        transitive = true;
    }
   }
   compileSdkVersion 21
   buildToolsVersion "21.1.2"

   defaultConfig {
        minSdkVersion 18
        targetSdkVersion 21


        // Enabling multidex support.
        multiDexEnabled true
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }
   }
Turnout answered 18/3, 2015 at 10:35 Comment(3)
Also I am using the Java Version 1.8.0_40 and Gradle Version: 2.2.1. Can anybody tell me what can be the root cause of the problemTurnout
Did you find any answer to this?Trichomonad
#26697618Flagellate
L
9

if you still have trouble with building the gradle after looking all the topics in Stack like i did for the past two days, there might be something else you should check if you used to use "Proxy" before, there's two file called gradle.properties in your gradle package.

if you've used a proxy before there's a possibility that android studio added that information in one of those gradle.properties file, so take a look at them both and if you see anything like:

systemProp.https.proxyHost=your_proxy_host
systemProp.https.proxyPort=your_proxy_port
systemProp.https.proxyUser=your_proxy_username
systemProp.https.proxyPassword=your_proxy_password

or

systemProp.http.proxyHost=your_proxy_host
systemProp.http.proxyPort=your_proxy_port
systemProp.http.proxyUser=your_proxy_username
systemProp.http.proxyPassword=your_proxy_password

just remove them, the then invalidate cache and restart your android studio and run the project I'm sure you will be fine.

Lillielilliputian answered 2/5, 2018 at 12:48 Comment(0)
S
3

1) You should sync with remote repos, with something like

mvn install - U

or in Android Studio or IntelliJ Idea go to Settings find Maven group, find subgroup Repositories and click Update on fabrics repo.

enter image description here

2) If it doesn't help you should switch to jcenter() instead mavenCentral(), because fabric.io developers pushing updates to jcentral() and mavenCentral() might be outdated. More about difference between two: Android buildscript repositories: jcenter VS mavencentral

Sly answered 29/3, 2015 at 15:39 Comment(0)
O
1

For anyone still facing this problem, here's what you need to do:

  1. Read the answer by Arash Afsharpour
  2. Follow what he says

If the problem still persists:

There's a global .gradle/gradle.properties file somewhere in your system (In my case, it was in my Users home directory). This file has your proxy settings stored. Comment these lines.

This should get your project up and running.

Cheers!

Outherod answered 22/3, 2020 at 4:49 Comment(0)
D
0

This can occur when you are behind a proxy

Dogmatics answered 17/1, 2017 at 15:28 Comment(3)
please explain.Creeper
For instance, on a Linux VM with NAT/PAT connexion to host, it will fail, but in bridged mode, il will be ok.Affray
More mundanely: If you have a company VPN and you forgot to log into it, this error can occurActium
H
0

For me, it was due to the heap size increase I did for my release build.

I just commented the following line from my gradle.properties file:

org.gradle.jvmargs=-Xms1024m -Xmx4096m

did ./gradlew clean and it works fine now.

Hominid answered 19/9, 2020 at 15:36 Comment(0)
F
0

I got this error on Visual Studio ( OS env : MacOS ) The simplest solution was to completely close the Visual Studio. i.e. Exit Visual Studio from the Dock as well.

Filaria answered 9/5, 2022 at 14:36 Comment(0)
V
-2

Turn on

Offline work

in settings -> Build,Execution... -> Gradle

Voleta answered 26/9, 2019 at 10:42 Comment(3)
While this is not an answer, Please use comment section to ask additional or supplementary question. Thanks.Fastigiate
I can not add a comment until i get 50 reputations.Voleta
that don't mean you write comment as answer. readFastigiate

© 2022 - 2024 — McMap. All rights reserved.