Gradle同步无法在Android Studio上打开Kotlin项目

时间:2019-07-02 19:50:52

标签: android-studio kotlin

在Android Studio上打开我的Kotlin项目时遇到问题。我该怎么办才能解决问题?我收到的错误日志是:

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.2.
Show Details
Affected Modules: app
...
...

1 个答案:

答案 0 :(得分:0)

转到File->Settings->Build, Execution, Deployment->Build Tools->Gradle,然后取消选中Offline work选项。点击“应用并确定”。再次同步gradle.build文件。

如果错误仍然存​​在,请转到File->Invalidate Caches/Restart,然后从对话框中选择Invalidate and Restart

如果在同步库文件时仍然存在任何问题,请检查下面的maven部分是否与项目级build.gradle文件中的下面部分相同:

allprojects {
     repositories {
         jcenter()
         maven {
             url "https://maven.google.com"
         }
     }
}