V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
OIseekU
V2EX  ›  Android

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

  •  
  •   OIseekU · 2016-11-24 22:47:54 +08:00 · 7753 次点击
    这是一个创建于 2715 天前的主题,其中的信息可能已经有所发展或是发生改变。

    求助一下,我现在 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

    第 1 条附言  ·  2016-11-28 23:43:36 +08:00

    这是Android studio sync时候的抓包

    这是直接采用浏览器访问链接的抓包

    第 2 条附言  ·  2016-11-29 21:22:36 +08:00

    top层面的build.gradle

    app层面的build.gradle

    第 3 条附言  ·  2016-11-29 22:54:03 +08:00

    19 条回复    2016-11-30 02:34:35 +08:00
    1stlulu
        1
    1stlulu  
       2016-11-24 23:41:25 +08:00 via iPhone
    抓个包看看请求怎么样了?
    KNOX
        2
    KNOX  
       2016-11-25 08:58:08 +08:00
    是哪个库?
    zhaohui318
        3
    zhaohui318  
       2016-11-25 09:18:26 +08:00
    是不是这个包没在 jcenter
    lowwor
        4
    lowwor  
       2016-11-25 13:26:36 +08:00
    先看看能不能在 jcenter.bintray.com 里找到那个包和对应的版本吧吧。
    OIseekU
        5
    OIseekU  
    OP
       2016-11-28 20:35:55 +08:00
    @1stlulu 怎样抓包?我用浏览器能够访问?你说的是用 wireshark 抓?
    OIseekU
        6
    OIseekU  
    OP
       2016-11-28 20:36:30 +08:00
    @KNOX 随便哪个第三方库都会报错 比如 compile 'com.github.ctiao:DanmakuFlameMaster:0.6.1'
    OIseekU
        7
    OIseekU  
    OP
       2016-11-28 20:37:39 +08:00
    @zhaohui318
    @lowwor 在 jcenter 里面能够找到 目前更新了 gradle 版本为 3.0 插件是 2.2 as 版本是 2.2 依旧报错
    OIseekU
        8
    OIseekU  
    OP
       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
        9
    1stlulu  
       2016-11-28 20:46:38 +08:00 via Android
    不建议用命令行 gradlew
    Android Studio 创建项目时用的 gradle 版本在线上没有,但在 Android Studio 里能访问到。
    OIseekU
        10
    OIseekU  
    OP
       2016-11-28 20:51:57 +08:00
    @1stlulu 嗯 那我应该怎么办 这问题纠结了很久 各种办法都试过了 无解啊
    OIseekU
        11
    OIseekU  
    OP
       2016-11-28 23:44:50 +08:00
    @1stlulu
    @KNOX
    @zhaohui318
    @lowwor
    麻烦看下 append 多谢
    1stlulu
        12
    1stlulu  
       2016-11-29 04:41:03 +08:00
    第一个图里面
    get 的端口是 8080
    然后 get 的东西 带了 protocol 和 domain name
    搞清楚什么导致的这两个问题 应该就能解决掉了
    KNOX
        13
    KNOX  
       2016-11-29 08:55:10 +08:00
    把 module 和 project 的 build 文件截图看看?
    lowwor
        14
    lowwor  
       2016-11-29 09:22:54 +08:00
    119.147.21.180 的 ip 是腾讯的。
    OIseekU
        15
    OIseekU  
    OP
       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
        16
    OIseekU  
    OP
       2016-11-29 21:12:17 +08:00
    @1stlulu as 所有能设置代理的地方都找了 setting 、 Android studio manager 、 gradle.properties 都搞了 没效果,是不是我的老版本的 as 遗留了什么配置文件影响了新版本的 as 呢
    OIseekU
        17
    OIseekU  
    OP
       2016-11-29 21:23:07 +08:00
    @KNOX 看 append 谢谢
    OIseekU
        18
    OIseekU  
    OP
       2016-11-29 22:56:48 +08:00
    好吧 问题已经解决 在 C:\Users\xxx\.gradle 文件夹下的 gradle.properties 文件里的代理信息注释掉即可。
    谢谢各位!
    ibigbug
        19
    ibigbug  
       2016-11-30 02:34:35 +08:00
    没想到刚刚我也遇到一样的问题。看来明天把撸油器全局翻墙关了试试。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2252 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 03:04 · PVG 11:04 · LAX 20:04 · JFK 23:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.