解析compileClasspath的依赖项时出错

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

我在android studio上的项目运行正常,然后今天我重新打开它,无法构建gradle。它在我的应用程序级别gradle中显示错误。我尝试将代码复制到另一个项目,但是当我尝试集成google的gms插件时,它的gradle也崩溃了。

我已经尝试更改插件的版本,但没有帮助。

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.abc.xyz"
        minSdkVersion 22
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-database:19.2.1'
    implementation 'com.google.firebase:firebase-auth:19.2.0'
    implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta01'

    implementation 'com.google.android.material:material:1.0.0'

    implementation 'com.commit451:PhotoView:1.2.4'

    implementation 'androidx.navigation:navigation-fragment:2.2.1'
    implementation 'androidx.navigation:navigation-ui:2.2.1'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    implementation 'com.google.zxing:core:3.3.0'

    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

    implementation 'com.squareup.okhttp:okhttp:2.7.5'

    implementation 'com.github.ivbaranov:materiallettericon:0.2.3'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

apply plugin: 'com.google.gms.google-services'

错误消息是

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.navigation:navigation-runtime:[2.2.1].
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[17.2.2].
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.2].
Show Details
Affected Modules: app


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


ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.navigation:navigation-runtime:[2.2.1].
Show Details
Affected Modules: app


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


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


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


ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.navigation:navigation-runtime:[2.2.1].
Show Details
Affected Modules: app


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


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


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

请帮助!

编辑:这些设置在脱机gradle模式下可以正常工作,但是当我上网时,它们将无法构建。顶级gradle如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()


    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta02'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}
android android-studio gradle classpath
2个回答
0
投票

打开顶级gradle文件并添加类路径'com.google.gms:google-services:x.x.x':

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath 'com.google.gms:google-services:4.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

0
投票

好,显然我的gradle文件已损坏,我只是删除了.gradle文件夹并重建了项目,所以一切似乎都正常,感谢您的帮助。

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