Mubashir Ali
Mubashir Ali

Reputation: 83

Plugin with id 'com.google.gms:google-services' not found. Flutter

I am new to flutter framework. I am trying to install cloud firestore in flutter but got the problem. Below is my code and gradle files: Android/build.gradlew:

buildscript {
    // ext.kotlin_version = '1.2.31'
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:3.2.0'
    }
}

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

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

App/build.gradle is:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.barcode_app"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms:google-services'

After running flutter run -v or build it in android i got the error: 'ERROR: Plugin with id 'com.google.gms:google-services' not found.'

enter image description here

I tried to almost all the solution available on stackoverflow and github but the problem is still there.

Upvotes: 8

Views: 16150

Answers (3)

Lutfor Rahman
Lutfor Rahman

Reputation: 95

Just delete the google-services.json file and re configure the firebase with your project.

Upvotes: 0

Ali Yar Khan
Ali Yar Khan

Reputation: 1354

If the problem still persists after applying the Jmorris and Johnhunter solution, check this solution

The solution was:

Upgrade the Android Gradle plugin to 3.5.0
Upgrade the Google Services plugin to 4.3.3
Upgrade Gradle to 5.4.1 (the required Gradle version for this Android Gradle plugin version)

Upvotes: 0

jmorris
jmorris

Reputation: 398

At the bottom of your app/build.gradle file you've got:

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

This should actually be:

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

Notice the period between gms and google-services, instead of the colon.

EDIT: You're probably having this problem because Google's own docs (last edited 20 March) are incorrect. I've sent them feedback to have this corrected. Picture of typo in google doc archived here http://archive.is/4Ujuc

Actually Google is correct: classpath 'com.google.gms:google-services:4.2.0' is correct and apply plugin: 'com.google.gms.google-services' is also correct. One has a COLON and one has a PERIOD. but the names are so similar that it is easy to think they should be the same. Just remember "classpath" - COLON, "plugin" - PERIOD.

Upvotes: 18

Related Questions