1. 無法從網絡獲取 gradle-3.6.0.pom 文件
問題描述
具體表現爲 Sync Project with gradle file 之後報錯:
具體報錯信息爲:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'My Application'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.6.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.6.0.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.6.0/gradle-3.6.0.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.6.0/gradle-3.6.0.pom'.
> Connection reset
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'My Application'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:80)
at ...
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 8s
解決辦法
可以看出主要是無法從https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.6.0/gradle-3.6.0.pom
獲得資源文件。
我們可以改變AndroidStudio的默認配置,不用https。
具體打開 C:\Users\用戶名\.gradle\gradle.properties
文件
systemProp.http.proxyHost=fodev.org
systemProp.https.proxyPort=8118
systemProp.https.proxyHost=fodev.org
systemProp.http.proxyPort=8118
註釋掉其中 https 的兩項。即改爲:
systemProp.http.proxyHost=fodev.org
# systemProp.https.proxyPort=8118
# systemProp.https.proxyHost=fodev.org
systemProp.http.proxyPort=8118
保存之後重新點擊AndroidStudio的File -> Sync Project with gradle file
即可。
2. Android Studio設計編輯器不顯示
問題描述
Android studio design editor is unavailable until after a successful project sync
點擊AndroidStudio的File -> Sync Project with gradle file
之後發現報錯:
解決辦法
修改項目的Module.app的build.gradle
文件 ,註釋掉測試的依賴包
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'androidx.test.ext:junit:1.1.1'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
相關鏈接: