Android Studio 2.2 添加第三方依赖错误

2016-11-24 22:47:54 +08:00
 OIseekU

求助一下,我现在 Android Studio 版本是 2.2 ,现在采用在 app/build.gradle 中 dependencies 下添加 compile ‘’的方式添加第三方依赖, 但是总是报 Error:(25, 13) Failed to resolve: 的错误,试了各种方法,如取消 offline 模式,添加 allprojects ,以及给 jcenter 指定 url ( http 和 https ),都没有效果,也怀疑过网络问题,但是通过浏览器访问 https://jcenter.bintray.com/很快啊。因此非常纠结

错误提示为: Error:(25, 13) Failed to resolve:xxx.xxx.xxx:0.1.1

9059 次点击
所在节点    Android
19 条回复
1stlulu
2016-11-24 23:41:25 +08:00
抓个包看看请求怎么样了?
KNOX
2016-11-25 08:58:08 +08:00
是哪个库?
zhaohui318
2016-11-25 09:18:26 +08:00
是不是这个包没在 jcenter
lowwor
2016-11-25 13:26:36 +08:00
先看看能不能在 jcenter.bintray.com 里找到那个包和对应的版本吧吧。
OIseekU
2016-11-28 20:35:55 +08:00
@1stlulu 怎样抓包?我用浏览器能够访问?你说的是用 wireshark 抓?
OIseekU
2016-11-28 20:36:30 +08:00
@KNOX 随便哪个第三方库都会报错 比如 compile 'com.github.ctiao:DanmakuFlameMaster:0.6.1'
OIseekU
2016-11-28 20:37:39 +08:00
@zhaohui318
@lowwor 在 jcenter 里面能够找到 目前更新了 gradle 版本为 3.0 插件是 2.2 as 版本是 2.2 依旧报错
OIseekU
2016-11-28 20:40:59 +08:00
@1stlulu
@KNOX
@zhaohui318
@lowwor
以下是运行命令 gradlew check --info 的结果
==========================
D:DanmuTestGL>gradlew check --info
Initialized native services in: C:\Users\Administrator\.gradle\native
Connected to daemon DaemonInfo{pid=8756, address=[4215a82d-68e5-4794-9252-05565f6ca25f port:54733, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]], idle=true, lastBusy=1480335284211, context=De
faultDaemonContext[uid=2cc9bc87-3441-40f0-82c4-fb7583eb3da4,javaHome=C:\Program Files\Java\jdk1.8.0_45,daemonRegistryDir=C:\Users\Administrator\.gradle\daemon,pid=8756,idleTimeout=1080000
0,daemonOpts=-Xmx1536m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]}. Dispatching request Build{id=b272fe58-a3ed-41b9-9885-80adb3dc2d4a.1, currentDir=D:\ASproj
ect\DanmuTestGL}.
Received result org.gradle.launcher.daemon.protocol.BuildStarted@37e4d7bb from daemon DaemonInfo{pid=8756, address=[4215a82d-68e5-4794-9252-05565f6ca25f port:54733, addresses:[/127.0.0.1,
/0:0:0:0:0:0:0:1]], idle=true, lastBusy=1480335284211, context=DefaultDaemonContext[uid=2cc9bc87-3441-40f0-82c4-fb7583eb3da4,javaHome=C:\Program Files\Java\jdk1.8.0_45,daemonRegistryDir=
C:\Users\Administrator\.gradle\daemon,pid=8756,idleTimeout=10800000,daemonOpts=-Xmx1536m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]} (build should be startin
g).
The client will now receive all logging from the daemon (pid: 8756). The daemon log file: C:\Users\Administrator\.gradle\daemon\3.0\daemon-8756.out.log
Starting 4th build in daemon [uptime: 12 mins 28.124 secs, performance: 96%, no major garbage collections]
Executing build with daemon context: DefaultDaemonContext[uid=2cc9bc87-3441-40f0-82c4-fb7583eb3da4,javaHome=C:\Program Files\Java\jdk1.8.0_45,daemonRegistryDir=C:\Users\Administrator\.gra
dle\daemon,pid=8756,idleTimeout=10800000,daemonOpts=-Xmx1536m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]
Starting Build
Settings evaluated using settings file 'D:\ASproject\DanmuTestGL\settings.gradle'.
Projects loaded. Root project using build file 'D:\ASproject\DanmuTestGL\build.gradle'.
Included projects: [root project 'DanmuTestGL', project ':app']
Evaluating root project 'DanmuTestGL' using build file 'D:\ASproject\DanmuTestGL\build.gradle'.
Resource missing. [HTTP GET: http://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom]
Resource missing. [HTTP HEAD: http://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.jar]

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'DanmuTestGL'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:2.2.0.
Searched in the following locations:
http://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom
http://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.jar
Required by:
:DanmuTestGL:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 1.579 secs
Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'DanmuTestGL'
.] from daemon DaemonInfo{pid=8756, address=[4215a82d-68e5-4794-9252-05565f6ca25f port:54733, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]], idle=true, lastBusy=1480335284211, context=Default
DaemonContext[uid=2cc9bc87-3441-40f0-82c4-fb7583eb3da4,javaHome=C:\Program Files\Java\jdk1.8.0_45,daemonRegistryDir=C:\Users\Administrator\.gradle\daemon,pid=8756,idleTimeout=10800000,dae
monOpts=-Xmx1536m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]} (build should be done).
1stlulu
2016-11-28 20:46:38 +08:00
不建议用命令行 gradlew
Android Studio 创建项目时用的 gradle 版本在线上没有,但在 Android Studio 里能访问到。
OIseekU
2016-11-28 20:51:57 +08:00
@1stlulu 嗯 那我应该怎么办 这问题纠结了很久 各种办法都试过了 无解啊
OIseekU
2016-11-28 23:44:50 +08:00
@1stlulu
@KNOX
@zhaohui318
@lowwor
麻烦看下 append 多谢
1stlulu
2016-11-29 04:41:03 +08:00
第一个图里面
get 的端口是 8080
然后 get 的东西 带了 protocol 和 domain name
搞清楚什么导致的这两个问题 应该就能解决掉了
KNOX
2016-11-29 08:55:10 +08:00
把 module 和 project 的 build 文件截图看看?
lowwor
2016-11-29 09:22:54 +08:00
119.147.21.180 的 ip 是腾讯的。
OIseekU
2016-11-29 21:10:23 +08:00
@lowwor ip119.147.21.180 是对应 android-mirror.bugly.qq.com 这个域名的,这本是我 Android SDK Manager 设置的代理,他的端口是 8080 但是不应该影响到 Android studio 本身的代理啊 本身没设置代理,并且取消代理以后也不行 还是访问到这个 ip 去。
OIseekU
2016-11-29 21:12:17 +08:00
@1stlulu as 所有能设置代理的地方都找了 setting 、 Android studio manager 、 gradle.properties 都搞了 没效果,是不是我的老版本的 as 遗留了什么配置文件影响了新版本的 as 呢
OIseekU
2016-11-29 21:23:07 +08:00
@KNOX 看 append 谢谢
OIseekU
2016-11-29 22:56:48 +08:00
好吧 问题已经解决 在 C:\Users\xxx\.gradle 文件夹下的 gradle.properties 文件里的代理信息注释掉即可。
谢谢各位!
ibigbug
2016-11-30 02:34:35 +08:00
没想到刚刚我也遇到一样的问题。看来明天把撸油器全局翻墙关了试试。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/323101

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX