5

In one of my projects I need to use GoogleMaps and Firebase for notifications but the libraries of the service and the Firebase in place do not want to work.

buildscript {
    repositories {
        google()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.google.android.gms:play-services:8.4.0'
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://maven.google.com" }
}

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.online.app"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 8
        versionName "2.5"
        multiDexEnabled true
    }
    buildTypes {
        release {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }    
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v4:26.0.2'
    compile 'me.leolin:ShortcutBadger:1.1.6@aar'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.0@aar') {
        transitive = true;
    }
    compile "com.google.firebase:firebase-ads:11.8.0"
    compile "com.android.support:appcompat-v7:26.1.0"
    compile 'com.android.support:multidex:1.0.1'
}

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

Error:

Gradle sync failed: Plugin with id 'com.google.android.gms:play-services' not found.
Consult IDE log for more details (Help | Show Log) (2s 325ms)
1
  • Did the above build.gradle is inside app module build.gradle or root build.gradle ? Feb 20, 2018 at 10:12

3 Answers 3

5

change this:

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

to this:

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

check this for more info: https://developers.google.com/android/guides/google-services-plugin

8
  • Gradle sync failed: Plugin with id 'com.google.android.gms:play-services' not found. Feb 20, 2018 at 9:07
  • i did change --- Gradle sync failed: Could not find com.google.gms:google-services:3.1.1. Feb 20, 2018 at 9:10
  • change this classpath 'com.google.android.gms:play-services:8.4.0 to this classpath 'com.google.gms:google-services:3.1.1 Feb 20, 2018 at 9:12
  • 1
    change this maven { url 'https://maven.google.com/' name 'Google' } to this maven { url 'https://maven.google.com' } remove / and remove those: repositories { maven { url 'https://maven.fabric.io/public' } maven { url "https://maven.google.com" } } in the other file Feb 20, 2018 at 9:42
  • 1
    I downloaded google-services-3.1.0.jar and google-services-3.1.0.pom and placed at android-studio/gradle/m2repository/com/google/gms/google-services/3.1.0/ and it all worked Feb 20, 2018 at 10:27
1

You need to use

apply plugin: 'com.google.gms.google-services'
4
  • 1
    Gradle sync failed: Could not find com.google.gms:google-services:3.1.1. Feb 20, 2018 at 9:08
  • which version of Android studio you are using? Feb 20, 2018 at 9:15
  • In you application gradle change classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.google.gms:google-services:3.1.0' in dependency section of buildscript Feb 20, 2018 at 9:17
  • You need to update your Gradle version to 3.1.0 That will probably resolve your problem Feb 20, 2018 at 9:19
1

You have 2 errors:

In your buildscript block use the right plugin:

dependencies {
    classpath 'com.google.gms:google-services:3.1.1'
    // ...
}

Instead of classpath 'com.google.android.gms:play-services:8.4.0'

Then at the bottom you have also to change the name of the plugin:

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

instead of:

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

Also don't use 2 buildscript blocks.

Just remove this block, and add the repository and the plugin in the previous block:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.