'How to solve "The plugin cloud_firestore could not be built due to the issue above."
I'm still learning Firebase and Flutter. When I trying to connect a firebase first time an error comes up. I installed it step by step as in the Firebase website. But in Android Studio, the red color underline is showing the wrong thing. How can I fix this?
In this file, he shows the error. This is a file that was edited when installing Firebase
Project/app/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 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "kasun.com.flutterbookmanger"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex.1.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
This is the other file that was edited. Project/build.gradle file
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Solution 1:[1]
Try this:
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new FileNotFoundException("Flutter SDK not found. Define location with
flutter.sdk in the local.properties file.")
}
I had this issue and it had nothing to do with firebase.
Solution 2:[2]
Try to update gradle version and should work fine
in Proect/build.gradle file
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
...
...
then you must update it in YOUR_APPLICATION_FOLDER/gradle/wrapper/gradle-wrapper.properties to
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
this helped me with same error
Solution 3:[3]
I solve this problem by closed the app from emulator (memory) . and start it from the first,i hope that can help you too.
Solution 4:[4]
The magical command line "flutter clean" did the job for me
Solution 5:[5]
Include this line as the first line in your file android/settings.gradle
include ':app'
Like this image:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Luthermilla Ecole |
| Solution 2 | |
| Solution 3 | youssef chaoulid |
| Solution 4 | |
| Solution 5 | Filipe Piletti Plucenio |



