2016-03-28 49 views
0

我在ubuntu上使用android studio 1.5.1。 我想谷歌分析添加到我的Android app.So我跟着google analytic document,但是当我改变mavenCentral()来jcenter(),机器人工作室无法解决此类路径:当我按下“同步工程在Android Studio中,Gradle无法解析来自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 
    } 

与摇篮files`Button”,Android的工作室大约需要15分钟,最后说:

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

不过我用的,并没有使用代理,而结果是一样的。

  1. 为什么我不能连接到jcenter(),但我可以连接到mavenCentral()?
  2. 如何将Gradle与我的项目同步以实施Google Analytic?

谢谢。

// 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' 
+0

为什么要在您的buildscript类路径中添加com.google.gms:google-services:2.0.0-alpha6'?这似乎不是设置说明的一部分。 –

回答

0

我觉得你的网络被限制访问一些网站或从这些网站下载。

如果你在办公室工作,那么它可能有一个代理服务器。它限制下载Gradle依赖关系。

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.

0

尝试,这也 首先检查您的网络代理设置复制代理设置,如代理主机和端口号。去你的“gradle.properties”文件中的项目并粘贴这样

systemProp.http.proxyHost="copied proxy host" 
systemProp.http.proxyPort="copied proxy port" 

systemProp.https.proxyHost="copied proxy host" 
systemProp.https.proxyPort="copied proxy port" 

一般人粘贴HTTP系统支撑,但忘记HTTPS所以请贴都。

相关问题