如何解决“无法解决依赖关系”错误?

问题描述 投票:0回答:2

我突然收到此错误,而且我不知道如何解决。我已经在这里尝试了所有建议Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve,但对我没有任何帮助。我已经按照建议的方式将sourceCompatibility和targetCompatibility从1.7更新为JavaVersion.VERSION_1_8。

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[17.2.0].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-impl:[17.2.0].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-gass:[18.2.0].
Show Details
Affected Modules: app


...

这是我的build.gradle(项目):

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.android.guessit"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0-alpha10'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'

    //Firebase SDKs
    implementation 'com.google.firebase:firebase-core:17.2.0'
    implementation 'com.google.firebase:firebase-auth:19.1.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    implementation 'com.google.firebase:firebase-ads:18.2.0'
    implementation 'com.google.firebase:firebase-perf:19.0.0'
    implementation 'com.google.firebase:firebase-messaging:20.0.0'

    implementation "androidx.lifecycle:lifecycle-extensions:2.1.0"

    //Glide maybe later add code to proguard
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

    // Circle ImageView
    implementation 'de.hdodenhof:circleimageview:3.0.1'

    // CardView and GridLayout
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.gridlayout:gridlayout:1.0.0'

    // Facebook SDK and login
    implementation 'com.facebook.android:facebook-login:4.41.0'

    //image downloading and caching library for Android
    implementation 'com.squareup.picasso:picasso:2.71828'
}

apply plugin: 'com.google.gms.google-services'   // Google Play services Gradle plugin


而且misc.xml文件已自动更改(语言级别已更新)。也许这与错误有关。

同样在SDK管理器中,SDK 29也显示为部分安装,尽管我无法为此SDK安装其他任何东西。

我该如何解决?

android android-studio google-play-services
2个回答
0
投票

最近发生了类似的事情,

  1. 从项目目录中删除.idea文件夹
  2. 删除.iml文件
  3. 使捕获无效并重新启动

0
投票

转到SDK管理器-> SDK工具->安装“ Google Play服务”

© www.soinside.com 2019 - 2024. All rights reserved.