Gradle issue in flutter when using firebase

左心房为你撑大大i 提交于 2019-11-30 10:39:56

I have used this dependencies in my android/build.gradle file

classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'  

and used this version for firebase and google in pubspec.yaml

firebase_auth: 0.5.11
google_sign_in: 3.0.4
cloud_firestore: 0.7.3  

It works fine because at these versions gradle tooling was updated to match Android Studio 3.1.2.

Other firebase working versions:

firebase_admob: 0.5.5
firebase_analytic: 1.0.1
firebase_core: 0.2.4 
firebase_database: 1.0.1 
firebase_dynamic_links: 0.02
firebase_messaging: 1.0.2
firebase_performance: 0.0.3
firebase_remote_config: 0.0.4
firebase_storage: 0.3.7

This link solved the issue for me.

First I set dependencies in my pubspec.yaml to

dependencies:
  flutter:
    sdk: flutter
  cloud_firestore: ^0.8.2 

and ran flutter packages get in my IDE's terminal.

Also I had to change the minimum target SDK version:

  1. Open android/app/build.gradle, then find the line that says minSdkVersion 16.
  2. Change that line to minSdkVersion 21.
  3. Save the file.

Also, I had to open android/app/build.gradle, then add the following line as the last line in the file: apply plugin: 'com.google.gms.google-services'

Next, I had to open android/build.gradle, then inside the buildscript tag, add a new dependency:

buildscript {
   repositories {
       // ...
   }

   dependencies {
       // ...
       classpath 'com.google.gms:google-services:3.2.1'   // new
   }
}

After this my app finally ran on the android emulator.

The link has a more complete walkthrough if you get stuck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!