skip to Main Content

I have tried to search on stackoverflow and tried the solutions suggested in other stackoverflow questions of similar nature such as this and that but
I am still getting the following error Plugin [id: ‘com.google.gms.google-services’, version: ‘4.3.15’, apply: false] was not found when i try to integrate firebase into my flutter app.

My build.gradle(android) is as follows:

buildscript {
    ext.kotlin_version = '1.9.0'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'
    }
}
plugins {
  // Add the dependency for the Google services Gradle plugin
  id 'com.google.gms.google-services' version '4.3.15' apply false
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

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


tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

and my build.gradle(app) is as follows:

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 Exception("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'
}

def flutterMinSDk = localProperties.getProperty('flutter.minSdkVersion')?.toInteger()
if (flutterMinSDk == null) {
    flutterMinSDk = 30
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
classpath 'com.google.gms:google-services:4.3.15'
android {
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
    // add this line to support Java8 features
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig { 
        applicationId "com.example.SApp"
        minSdkVersion flutterMinSDk
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}
plugins {
  id 'com.android.application'
}
dependencies {
// add this line to support Java8 features
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-messaging:23.2.1'
}

I have also tried adding the firebase files using the cli via video
so the google-services.json is already in my app folder.

Any help would be greatly appreciated. Thanks.

2

Answers


  1. Please Add Google Service .json file from your firebase Project into your application
    For More Information Refer this Link:-
    https://firebase.flutter.dev/docs/overview/

    Login or Signup to reply.
  2. remove This line from your projects

    plugins {
       // Add the dependency for the Google services Gradle plugin
        id 'com.google.gms.google-services' version '4.3.15' apply false
      } 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search