【错误记录】Android Studio 编译报错 ( Error:Connection timed out: connect | 更新配置依赖仓库方式 )
生活随笔
收集整理的這篇文章主要介紹了
【错误记录】Android Studio 编译报错 ( Error:Connection timed out: connect | 更新配置依赖仓库方式 )
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 一、報錯信息
- 二、解決方案
一、報錯信息
編譯 VirtualAppEx 源碼時 , 報如下錯誤 :
Gradle 'VirtualAppEx-master' project refresh failed Error:Connection timed out: connect使用
gradlew assembleDebug --stacktrace命令 , 查看詳細報錯信息 :
D:\002_Project\002_Android_Learn\VirtualApp\003_VirtualAppEx\VirtualAppEx-master>gradlew assembleDebug --stacktrace Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for detailsFAILURE: Build failed with an exception.* What went wrong: A problem occurred configuring root project 'VirtualAppEx-master'. > Could not resolve all files for configuration ':classpath'.> Could not resolve com.android.tools.build:gradle:3.0.1.Required by:project :> Could not resolve com.android.tools.build:gradle:3.0.1.> Could not get resource 'https://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.> Could not HEAD 'https://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.> Connect to maven.google.com:443 [maven.google.com/142.251.43.14] failed: Connection timed out: connect> Could not resolve com.android.tools.build:gradle-experimental:0.11.0.Required by:project :> Could not resolve com.android.tools.build:gradle-experimental:0.11.0.> Could not get resource 'https://maven.google.com/com/android/tools/build/gradle-experimental/0.11.0/gradle-experimental-0.11.0.pom'.> Could not HEAD 'https://maven.google.com/com/android/tools/build/gradle-experimental/0.11.0/gradle-experimental-0.11.0.pom'.> Connect to maven.google.com:443 [maven.google.com/142.251.43.14] failed: Connection timed out: connect* Try: Run with --info or --debug option to get more log output.二、解決方案
下面這種依賴庫的配置方式無法獲取到 Gradle 編譯相關依賴庫 ;
repositories {jcenter()maven {url 'https://maven.google.com/'name 'Google'}}添加 google() 和 mavenCentral() 即可 ;
repositories {jcenter()google()mavenCentral()maven {url 'https://maven.google.com/'name 'Google'}}完整的 build.gradle 構建腳本如下 :
buildscript {repositories {jcenter()google()mavenCentral()maven {url 'https://maven.google.com/'name 'Google'}}dependencies {classpath 'com.android.tools.build:gradle:3.0.1'classpath 'com.android.tools.build:gradle-experimental:0.11.0'// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files} }allprojects {repositories {jcenter()google()mavenCentral()maven {url "https://jitpack.io"}maven {url 'https://maven.google.com/'name 'Google'}} }task clean(type: Delete) {delete rootProject.buildDir }修改完畢后可以正常編譯 ;
總結
以上是生活随笔為你收集整理的【错误记录】Android Studio 编译报错 ( Error:Connection timed out: connect | 更新配置依赖仓库方式 )的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【错误记录】Android Studio
- 下一篇: 【Android 插件化】Virtual