Unable to resolve dependency for ':app@debug/c

2019-06-18 17:34发布

问题:

I am getting this error: Here is my build.gradle(Module:app)

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.mycompany.myapp"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding.enabled = true
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.firebase:firebase-core:15.0.0'
    compileOnly "org.projectlombok:lombok:1.16.20"
    annotationProcessor 'org.projectlombok:lombok:1.16.20'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.code.gson:gson:2.8.1'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.google.android.gms:play-services-maps:15.0.0'
    implementation 'com.google.android.gms:play-services-location:15.0.0'
    implementation 'com.google.android.gms:play-services-places:15.0.0'
    implementation 'com.paytm.pgsdk:pgsdk:1.0.8'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.crashlytics.sdk.android:crashlytics:2.9.1'
}

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

and Here is my build.gradle(Project: myApp)

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'io.fabric.tools:gradle:1.25.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

I have checked other solutions, most of them suggest to add

maven { url "https://maven.google.com" }

to build.gradle of project. I have already tried this but I am still getting same error.

I am on android studio 3.0. I have also tried adding google() instead of maven (another suggestion)

回答1:

Go to File -> Other Settings -> Default Settings -> Build, Execution, Deployment -> Build Tools -> Gradle ->

And uncheck Offline work option.



回答2:

I had the same issue while use OneSignal to handle push notifications in my android application.

The solution is to add the exclude clause to its' dependency:

implementation ('com.onesignal:OneSignal:3.8.3'){
    exclude group: 'com.google.android.gms'
}

in the app folder, then add any other missing dependency manually such as:

implementation 'com.google.android.gms:play-services-appinvite:16.1.0'

The problem is that OneSignal SDK contains Google Play Service dependency that are not of the same version with the latest version of gms and firesbase I used in the app.

So I suggest you figure out a dependency you added that uses google play service in the project and use the exclude clause on it. Though your gradle should build if your system is connected to the internet.

Hope this is helpful.



回答3:

Using the VPN solved my problem.



回答4:

Just Build -> Clean Project worked for me



回答5:

I was using a VPN for internet connection. I closed VPN and it worked for me.



回答6:

Have you tried adding this in your dependencies:

implementation 'com.google.android.gms:play-services-basement:15.0.0'