本文介绍了Gradle 构建错误:无法从 https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml 加载 Maven 元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Android Studio 中遇到如下 gradle 构建错误:

    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

我发现https"标签无法下载 Maven URL,因此我在 build.gradle 文件中将 https 更改为 http.此外,我检查了所有 gradle 设置并手动修改路径 C:\Users\Ashfaque1.AndroidStudio\config\options\ 中的 other.xml 文件,但它仍然采用 https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml.此外,一旦我点击此链接到浏览器,我就会收到 404 异常,但错误中的第二个 URL http://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml,我能够成功点击并下载元数据文件在我的系统中正确.无法理解是什么问题,我需要更改设置以便下载元数据文件.请建议我是否需要更改任何设置或从何处获取此 URL https://repo1.maven.org/maven2//io/fabric/tools/gradle/maven-metadata.xml

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

我的 build.gradle 文件如下:

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"
    }
   }

推荐答案

如果像我过去两天那样在 Stack 中查看所有主题后仍然无法构建 gradle,则可能还有其他问题需要检查如果您以前使用过代理",那么您的 gradle 包中有两个名为 gradle.properties 的文件.

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.

如果您之前使用过代理,那么 android studio 有可能在其中一个 gradle.properties 文件中添加了该信息,那么请查看它们,如果您看到以下内容:

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

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

只需删除它们,然后使缓存无效并重新启动您的 android studio 并运行该项目,我相信您会没事的.

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

这篇关于Gradle 构建错误:无法从 https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml 加载 Maven 元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 06:20