自认为自己已经算是老鸟了,在使用Android Studio build的时候也总会遇到奇怪的问题,
例如:今天mac电脑在运行安卓项目时,遇到了这个问题:
FAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:javaPreCompileDebug'.> Could not resolve all files for configuration ':app:debugAnnotationProcessorClasspath'.> Could not download error_prone_annotations.jar (com.google.errorprone:error_prone_annotations:2.2.0)> Could not get resource ' https://jcenter.bintray.com/com/google/errorprone/error_prone_annotations/2.2.0/error_prone_annotations-2.2.0.jar'.> Could not GET ' https://jcenter.bintray.com/com/google/errorprone/error_prone_annotations/2.2.0/error_prone_annotations-2.2.0.jar'.> jcenter.bintray.com: nodename nor servname provided, or not known* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.* Get more help at https://help.gradle.orgBUILD FAILED in 7s26 actionable tasks: 22 executed, 4 up-to-date
解决方式:
在 gradle.properties 文件中加入如下配置:
systemProp.https.nonProxyHosts=localhost
#systemProp.https.proxyPort=1080
systemProp.http.proxyHost=127.0.0.1
systemProp.http.nonProxyHosts=localhost
#systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
参考博文: