3

This is all I have as my project's repositories:

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

This is all I have as my project's dependencies:

dependencies {
    compile 'com.google.android.gms:play-services:12.0.1'
    compile 'com.android.support:support-v13:27.1.1'

    compile 'com.android.support:support-core-ui:27.1.1'
    compile 'com.android.support:support-core-utils:27.1.1'

    compile 'com.google.android.gms:play-services-appinvite:16.0.0'
    compile 'com.google.firebase:firebase-core:16.0.0'

    compile 'com.google.android.gms:play-services-gcm:15.0.1'
    compile "com.android.support:support-core-utils:27.1.1"
    compile files('libs/dagger-1.2.2.jar')
    compile files('libs/javax.inject-1.jar')
    compile files('libs/nineoldandroids-2.4.0.jar')
    compile 'com.google.android.gms:play-services-ads:15.0.1'
    compile 'com.android.support:multidex:1.0.1'
}
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Ismail Hamdach
  • 127
  • 3
  • 8
  • Possible duplicate of [Gradle build tool cannot find play-services-tasks.aar? Why?](https://stackoverflow.com/questions/50562212/gradle-build-tool-cannot-find-play-services-tasks-aar-why) – Floern May 28 '18 at 13:15
  • 1) NineOldAndroids is deprecated. 2) Dagger and JavaX have their own Gradle targets. Don't use JAR files unless absolutely necessary. 3) Do not use `play-services:12.0.1` - Use only Google services you actually *need* (such as ads and appinvites). Also, each of those Google versions need to match exactly 4) GCM is being replaced by Firebase FCM – OneCricketeer May 28 '18 at 14:55

2 Answers2

15

I solved this issue by changing

allprojects {
    repositories {
        jcenter()
        google()
    }
}

into

allprojects {
    repositories {
        google()
        jcenter()
    }
}

in project level build.gradle file, i.e. first writing google().

Salman Khalid
  • 543
  • 5
  • 23
4

This is the answer:

buildscript {
    repositories {
        google()
        jcenter()
    }
}

allprojects {
    repositories {
        google()
        maven { url "https://maven.google.com" }
        jcenter()
    }
krlzlx
  • 5,752
  • 14
  • 47
  • 55
Ismail Hamdach
  • 127
  • 3
  • 8