Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"
    }
   }
like image 294
user2678020 Avatar asked Mar 18 '15 10:03

user2678020


3 Answers

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.

like image 112
Arash Afsharpour Avatar answered Oct 24 '22 05:10

Arash Afsharpour


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

like image 43
sigrlami Avatar answered Oct 24 '22 06:10

sigrlami


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!

like image 1
Ishan Sharma Avatar answered Oct 24 '22 07:10

Ishan Sharma