After starting a new Flutter project, I wanted to work with Firebase in my project, I added following to the project:
firebase_coreandfirebase_authto the pubspec.yaml- google-services.json to the corresponding path
classpath 'com.google.gms:google-services:4.3.6'to android/build.gradleimplementation platform('com.google.firebase:firebase-bom:28.0.0')to the "dependencies" in the app/build.gradle
Until now everything works well, but after adding this line to the app/build.gradle :
apply plugin: 'com.google.gms.google-services'
After adding this line and even without editing the application code, I got the following error message:
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\1337\StudioProjects\teest\android\build.gradle' line: 27
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method setVariantDir() for arguments [debug] on task ':app:processDebugGoogleServices' of type com.google.gms.googleservices.GoogleServicesTask.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Exception: Gradle task assembleDebug failed with exit code 1
This is my android/build.gradle
buildscript {...}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.6'
}
}
allprojects {...}
rootProject.buildDir = '../build'
subprojects {... }
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {...}
Ps: by running flutter doctor -v is everything fine.