Ошибка в разрешении зависимостей для compileClasspath - PullRequest
0 голосов
/ 11 февраля 2020

Мой проект на студии android работал нормально, а затем сегодня я снова открываю его, и gradle не может быть построен. Это показывает ошибку в моем Gradle уровня приложения. Я попытался скопировать код в другой проект, но его gradle также потерпел крах, когда я попытался интегрировать плагин gms от google.

Я уже пытался изменить версию для плагина, но это не помогло.

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, но когда я go онлайн, они не будут строить. 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()

    }
}

Ответы [ 2 ]

0 голосов
/ 11 февраля 2020

ОК, так что, очевидно, мои файлы gradle были повреждены, я просто удалил папку .gradle и перестроил проект, и все вроде работает нормально, спасибо за помощь.

0 голосов
/ 11 февраля 2020

Откройте файл Gradle верхнего уровня и добавьте classpath 'com.google.gms: google-services: xxx' следующим образом:

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
    }
}
...