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.
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. 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With