Reputation: 5397
I want to use Firebase for my application, but whenever I add a firebase specific dependency (ex: "cloud_firestore:" or "firebase_analytics: ^0.3.3") I cannot build the app. When I do flutter run I receive the following output:
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... 4.4s
Resolving dependencies... 19.1s
Running 'gradlew assembleDebug'...
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
FAILURE: Build failed with an exception.
* What went wrong:
Failed to notify dependency resolution listener.
> The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.4,15.0.4]], but
resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
> The library com.google.firebase:firebase-analytics is being requested by various other libraries at [[16.0.0,16.0.0]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 16s
Gradle build failed: 1
Upvotes: 0
Views: 709
Reputation: 126694
As explained here you need to add Android dependencies if you want to run Firebase on Android.
In your build.gradle
project level file, you need to add:
dependencies {
// other dependencies might already be here
classpath 'com.google.gms:google-services:3.1.2'
}
To your app level build.gradle
, add at the very bottom:
apply plugin: 'com.google.gms.google-services'
Not every Firebase plugin page for Dart has this information. Another great source is this codelab, as it shows how to integrate with Android and iOS.
Also, when using Android, make sure that your device has Google Play services installed.
Upvotes: 1