Gradle无法解析Android Studio中jcenter()的依赖类路径 [英] Gradle cannot resolve dependencies classpath from jcenter() in Android studio

查看:550
本文介绍了Gradle无法解析Android Studio中jcenter()的依赖类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ubuntu上使用android studio 1.5.1。
我想将 google analytic 添加到我的Android应用中。因此,我遵循 google分析文档,但是当我将mavenCentral()更改为jcenter()时,Android Studio无法解析此类路径:

 依赖关系{
classpath'com.android.tools.build:gradle:2.0.0-beta6'
classpath'com.google.gms :google-services:2.0.0-alpha6'
//注意:不要在这里放置您的应用程序依赖关系;它们属于单个模块build.gradle文件
//
$ b $ /当我按下与Gradle文件同步项目按钮时,Android Studio花费大约15分钟,最后说:


错误:连接超时。如果您使用的是HTTP代理,请
在IDE或Gradle中配置代理设置。


然而,为什么我无法连接到jcenter(),但我可以连接到mavenCentral()?为什么我不能连接到jcenter(),但我可以连接到mavenCentral()? / li>

  • 如何将gradle与我的项目同步以实施Google Analytics?

  • p>

      //顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。 
    buildscript {
    repositories {
    jcenter()
    }
    依赖关系{
    classpath'com.android.tools.build:gradle:2.0.0- beta6'
    classpath'com.google.gms:google-services:2.0.0-alpha6'
    //注意:不要在这里放置您的应用程序依赖关系;它们属于单个模块build.gradle文件中的
    // b

    $ b allprojects {
    存储库{
    jcenter()
    }
    }
    任务清理(类型:删除){
    删除rootProject.buildDir
    }

    =============================

      compile'c​​om.google.android.gms:play-services:8.4.0'


    解决方案

    我认为您的广告联盟仅限于访问某些网站或从这些网站下载。 如果你在办公室工作,那么它可能有一个代理服务器。它限制下载Gradle依赖关系。 b
    $ b


    代理服务器或代理服务器基本上是另一台计算机,它充当处理互联网请求的中心。通过连接这些服务器之一,您的计算机将您的请求发送到代理服务器,然后处理您的请求并返回您想要的内容。



    I`m using android studio 1.5.1 on ubuntu. I want to add google analytic to my android app.So I followed google analytic document but when I change mavenCentral() to jcenter() , Android studio cannot resolve this classpath:

    dependencies {
            classpath 'com.android.tools.build:gradle:2.0.0-beta6'
            classpath 'com.google.gms:google-services:2.0.0-alpha6'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    

    When I press "sync project with Gradle files`Button" , Android studio take about 15 minutes and finally says :

    Error:Connection timed out. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.

    However I used and did not used proxy , And result was same.

    1. Why I cannot connect to jcenter() but I can connect to mavenCentral()?
    2. How can I sync gradle with my project to implement Google Analytic ?

    Thanks.

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.0.0-beta6'
            classpath 'com.google.gms:google-services:2.0.0-alpha6'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    allprojects {
        repositories {
            jcenter()
        }
    }
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    =============================

    compile 'com.google.android.gms:play-services:8.4.0'
    

    解决方案

    I think your network is restricted to access some sites or download from those sites.

    If you are working from your office then it may have a proxy server. and it is restricting from downloading Gradle dependencies.

    A proxy or proxy server is basically another computer which serves as a hub through which internet requests are processed. By connecting through one of these servers, your computer sends your requests to the proxy server which then processes your request and returns what you were wanting.

    这篇关于Gradle无法解析Android Studio中jcenter()的依赖类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆