Overnight I had this problem. Here is my build_gradle:
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 plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.game_rewards"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms.google-services:4.3.10'
}
My error is :
Build file ‘C:UsersantoiDocumentsprogrammationlangagesfluttergame_rewardsandroidbuild.gradle’ line: 12
- What went wrong:
A problem occurred evaluating root project ‘android’.
Plugin with id ‘com.google.gms.google-services’ not found.
I don’t know why and can you please help me correct the errors. Thank you for your reply
2
Answers
The error says that the plugin is not found because it is not added as dependency. You added the line but in a wrong place. Follow below for correcting it.
This is the link you followed to initialize https://firebase.flutter.dev/docs/manual-installation/android
Your code: (
android/app/build.gradle
)This line in the above code causes the issue. From the initialisation, this line shouldn’t be here and instead be in
android/build.gradle
So, this part should look like
Add this below line to
android/build.gradle
which should look like
The above is directly from the link.
Please update your gradle version in build.gradle under project directory and rebuild again.