jcenter.bintray.com: nodename nor servname provided, or not known
gradle加载的依赖编译不过
现象:
部署应用时提示如下错误,gradle不能成功下载热修复所需的资源
* What went wrong:
A problem occurred configuring root project 'jjcx_buzz'.
> Could not resolve all files for configuration ':classpath'.
> Could not download aosp-dexutils.jar (com.tencent.tinker:aosp-dexutils:1.9.6)
> Could not get resource 'https://jcenter.bintray.com/com/tencent/tinker/aosp-dexutils/1.9.6/aosp-dexutils-1.9.6.jar'.
> Could not GET 'https://jcenter.bintray.com/com/tencent/tinker/aosp-dexutils/1.9.6/aosp-dexutils-1.9.6.jar'.
> jcenter.bintray.com: nodename nor servname provided, or not known
> Could not download bsdiff-util.jar (com.tencent.tinker:bsdiff-util:1.9.6)
> Could not get resource 'https://jcenter.bintray.com/com/tencent/tinker/bsdiff-util/1.9.6/bsdiff-util-1.9.6.jar'.
> Could not GET 'https://jcenter.bintray.com/com/tencent/tinker/bsdiff-util/1.9.6/bsdiff-util-1.9.6.jar'.
> jcenter.bintray.com
> Could not download tinker-ziputils.jar (com.tencent.tinker:tinker-ziputils:1.9.6)
> Could not get resource 'https://jcenter.bintray.com/com/tencent/tinker/tinker-ziputils/1.9.6/tinker-ziputils-1.9.6.jar'.
> Could not GET 'https://jcenter.bintray.com/com/tencent/tinker/tinker-ziputils/1.9.6/tinker-ziputils-1.9.6.jar'.
> jcenter.bintray.com
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
我在gradle的配置中是这样做的
//热修复
compile "com.android.support:multidex:1.0.1"
//其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.2.0
compile 'com.tencent.bugly:crashreport_upgrade:latest.release'
//其中latest.release指代最新版本号,也可以指定明确的版本号,例如2.2.0
compile 'com.tencent.bugly:nativecrashreport:latest.release'
这样自动下载所需的依赖库,之前运行也都一直良好。
出现的原因:
大概是因为腾讯对热修复的包进行了更新,而我的gradle因为配置了每次加载最新依赖。那么在新依赖不能下载成功是,就提示出这样的错误。程序不能编译成功。
解决办法
1.把资源用浏览器下载下来放到对应的目录下
如何查找gradle下载的资源目录呢?
找到android studio下所依赖的lib集合,如下图,点击其中任意一个lib库右键可以查看到它所在的目录。
下面的这个路径是可以拷贝出来的
在文件夹中打开对应目录如下图,把下载好的”.jar”文件放到对应的目录下
路径在mac下取到的是:
/Users/sun/.gradle/wrapper/dists/gradle-3.3-all/caches/modules-2/files-2.1/com.tencent.bugly/crashreport_upgrade/1.3.4/e4284aa963729dcc2060f45cd9186ecf42c2e116/crashreport_upgrade-1.3.4-sources.jar
2.修改gradle中引用依赖的配置为固定的版本。
如何查看上次引用的依赖的版本号?
将工程目录调为project模式,找到所有依赖的lib打开进行查看,然后就可以看到引用的依赖库。
【参考资料】
Gradle 下载的依赖包在什么位置?