本文介绍了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