Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

build.gradle error , Failed to resolve: common [duplicate]

Tags:

Today suddenly, I got an error when I tried to run my app in Android studio.

It is:

Error: Could not find play-services-tasks.aar (com.google.android.gms:play-services-tasks:15.0.1).
Searched in the following locations:
    https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/15.0.1/play-services-tasks-15.0.1.aar

gradle_build_error

I didn't change anything in the gradle file but it appeared suddenly. My previous build executed successfully some minutes ago.

Why it can't find play-services-tasks.aar which is the part of com.google.android.gms:play-services-tasks:15.0.1

Steps taken:

I checked whether I included all repositories in the gradle files and all are correct so far.

Why does this error occur all of a sudden?

I also copied this link https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/15.0.1/play-services-tasks-15.0.1.aar into the browser but it's working fine, that is, I got "File Download" dialog.


My Gradle Files

  • App level

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.2"
        defaultConfig {
            applicationId "mekanic24assistantapplication.heba.mekanic24.com.mekanic24assistantapplication"
            minSdkVersion 14
            targetSdkVersion 26
            versionCode 13
            versionName "2.1"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
    
        dexOptions {
            incremental true
            javaMaxHeapSize "4g"
        }
    
    //    err Android Gradle Duplicate files copied in APK META-INF/license.txt
    
        configurations.all {
    
            resolutionStrategy {
                force 'com.android.support:support-v4:26+'
                force 'com.android.support:support-annotations:26+'
    
    
            }
    
        }
    
    
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/dependencies.txt'
            exclude 'META-INF/LGPL2.1'
        }
    
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        //   compile 'com.android.support:appcompat-v7:26.3.1'
        compile 'com.android.support:appcompat-v7:26+'
        compile 'com.android.support:design:26+'
        compile 'com.android.support:recyclerview-v7:26+'
        compile 'com.android.support:cardview-v7:26+'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        androidTestCompile 'com.android.support:support-annotations:26+'
        testCompile 'junit:junit:4.12'
        //   compile 'com.android.support:appcompat-v7:26.3.1'
        compile 'com.github.markushi:circlebutton:1.1'
        //  compile 'com.android.support:design:26.3.1'
        compile 'com.android.volley:volley:1.0.0'
        compile 'com.google.android.gms:play-services-base:15.0.1'
        compile 'com.android.support:multidex:1.0.1'
        compile 'com.firebase:firebase-client-android:2.5.2'
        compile 'com.google.firebase:firebase-core:15.0.2'
        compile 'com.google.firebase:firebase-messaging:15.0.2'
        compile 'com.google.firebase:firebase-database:15.0.0'
        compile 'com.wang.avi:library:2.1.3'
        compile 'de.hdodenhof:circleimageview:2.2.0'
        compile 'android.lib.recaptcha:reCAPTCHA:2.0.0'
        compile 'com.google.android.gms:play-services-safetynet:15.0.1'
        compile 'com.google.android.gms:play-services-maps:15.0.1'
        compile 'com.google.android.gms:play-services-places:15.0.1'
        compile 'com.google.android.gms:play-services-location:15.0.1'
    
        compile 'com.squareup.picasso:picasso:2.5.2'
        testCompile 'junit:junit:4.12'
        compile 'com.anjlab.android.iab.v3:library:1.0.38'
        compile files('libs/mail.jar')
        compile files('libs/additionnal.jar')
        compile files('libs/activation.jar')
        compile 'com.jakewharton:butterknife:8.8.1'
        annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
        compile 'com.yarolegovich:lovely-dialog:1.1.0'
        compile 'com.mobsandgeeks:android-saripaar:2.0.3'
        compile 'com.github.stfalcon:smsverifycatcher:0.3.1'
        compile 'ch.acra:acra:4.9.0'
        //TODO:  Apache 2.0 license https://github.com/ACRA/acra
        compile 'com.google.android.gms:play-services-ads:15.0.1'
        compile 'com.github.luongvo:GmailBackground:2.0.2'
    
    }
    apply plugin: 'com.google.gms.google-services'
    
  • Project Level

    buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        maven {
            url "https://dl.bintray.com/android/android-tools"
        }
    
        maven { url "https://jitpack.io" }
        google()
    
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
    
        classpath 'com.google.gms:google-services:3.2.0'
    }
    }
    
    allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        maven {
            url "https://dl.bintray.com/android/android-tools"
        }
    
        maven { url "https://jitpack.io" }
        google()
    
    }
    }
    
    task clean(type: Delete) {
    delete rootProject.buildDir
    }
    
like image 839
Lord Commander Avatar asked May 28 '18 08:05

Lord Commander


People also ask

Why is my Gradle build so slow?

This happens due to the fact that the module needs to be built from the scratch every time. Enable gradle Offline Work from Preferences-> Build, Execution, Deployment-> Build Tools-> Gradle. This will not allow the gradle to access the network during build and force it to resolve the dependencies from the cache itself.


2 Answers

After doing the following changes the error disappeared:

  1. Removed maven { url 'https://maven.google.com' } from repositories in app build.gradle.
  2. Added maven { url 'https://maven.google.com' } as first entry in allprojects/repositories in top level build.gradle
  3. Changed all play-services and firebase dependencies to the latest versions
  4. Changed version of google-services plugin to classpath 'com.google.gms:google-services:4.0.1'
like image 123
Ivan Rigamonti Avatar answered Oct 03 '22 17:10

Ivan Rigamonti


The fix is to put google url above jcenter() in your repository list in gradle.

Here's the issue: https://issuetracker.google.com/issues/80362794

like image 44
Sergio Avatar answered Oct 03 '22 18:10

Sergio