最近遇到一个Android环境问题,搞得头都大了。公司电脑上的android环境一直都是好的 最近加了一个内网的依赖包 然后死活都拉不下来这个依赖 一直报错
Error:Failed to resolve: com.vpal.im.android:im-client-sdk-withLongSocket:2.0.20
<a href="openFile:F:/android-project/vf-android/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
这个依赖是在内网的maven仓库(http://nexus.tools.vip.com/content/repositories/releases/
)
这样的话内网的依赖就拉不下来 这里只是新加的依赖拉不下来 之前已经拉下来的内网依赖由于已经存在cache,所以不会报错,那么问题找到了 把proxy关掉好了。
以为搞定了,没想到重新同步一下之后又报错了
Error:Failed to resolve: com.crashlytics.sdk.android:crashlytics-ndk:1.1.6
<a href="openFile:F:/android-project/vf-android/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
这个是https://maven.fabric.io/public这个maven中的,由于把代理去掉了,所以外网的(需要翻墙的)依赖就找不到了。头疼。。。
突然看到Http Proxy中不是有No proxy for选项吗?于是把代理打开,内网的host在这里忽略掉就行了。
从新同步了一下没有报错,搞定!就这个破问题搞了我一整天,还以为是网络出了问题,找来公司的网络管理员来排查也没有解决。Androidstudio真是越来越麻烦了 尤其是升级新版本gradle3.1.2之后带来各种报错和不兼容。小记一下!
第二记:
又被坑了,我发现把代理删掉,一直拉不下来内网依赖,主要是因为还有个gradle的全局代理在.gradle目录下的gradle.properties中
检查代理几个地方:
1.项目根目录的gradle.properties 这里会有代理设置
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx8704m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.parallel=true
android.useDeprecatedNdk=true
# COMPILE_SDK_VERSION=25
# BUILD_TOOLS_VERSION=25.0.0
# SUPPORT_LIB_VERSION=25.1.1
# MIN_SDK_VERSION=16
# TARGET_SDK_VERSION=25
# JENKINS_BUILD_NUMBER= "#1"
#systemProp.http.proxyPort=443
#systemProp.http.proxyUser=keke.tian
#systemProp.http.proxyPassword=
#systemProp.https.proxyPassword=
#systemProp.https.proxyHost=bj-proxy.tools.vipshop.com
#systemProp.http.nonProxyHosts=*.*.vip.*,*.*.vipshop.*
#systemProp.http.proxyHost=bj-proxy.tools.vipshop.com
#systemProp.https.proxyPort=443
#systemProp.https.nonProxyHosts=*.*.vip.*,*.*.vipshop.*
#systemProp.https.proxyUser=keke.tian
这里看一下需要的话就打开,不需要的话就注释掉
2.这里只是项目中的代理,但是还有一个地方是.gradle的目录下还有个gradle.properties
这里如果打开了代理 那么你所有的android项目和java项目都会默认用代理去下载内网依赖,然后就下载不下来。真的被坑死了。。。
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Wed Jul 25 14:23:37 CST 2018
#systemProp.http.proxyPort=443
#systemProp.http.proxyUser=keke.tian
#systemProp.http.proxyPassword=
#systemProp.https.proxyPassword=
#systemProp.https.proxyHost=bj-proxy.tools.vipshop.com
#systemProp.http.nonProxyHosts=*.*.vip.*,*.*.vipshop.*
#systemProp.http.proxyHost=bj-proxy.tools.vipshop.com
#systemProp.https.proxyPort=443
#systemProp.https.nonProxyHosts=*.*.vip.*,*.*.vipshop.*
#systemProp.https.proxyUser=keke.tian
网友评论