Gradle error when building Flutter apk after adding firebase

Gradle error when building Flutter apk after adding firebase

flutter firebase
flutter firebase auth
firebase core flutter
firebase crashlytics flutter
flutter firebase ios
flutter firebase messaging
flutter web firebase
flutter firebase analytics

I want to implement Firebase Cloud Messaging into my Flutter application and i started to implement the Android part. I added the dependencies just like in the Firebase documentation, but now I'm getting gradle error when building my app:

The library com.google.firebase:firebase-iid is being requested by various other libraries at [[16.0.0,16.0.0]], but resolves to 15.1.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

I'm not experienced at all with gradle, so I would appreciate some help^^

Here is 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.")
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 27

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.leodr.pguapp"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        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.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.0.0'
}

apply plugin: 'com.google.gms.google-services'

And here is the project build.gradle(if needed):

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:4.0.0'
    }
}

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
}

Downgrade the gms version on your build.gradle to classpath 'com.google.gms:google-services:3.2.1'

[all] Flutter Android build fails with firebase dependencies. · Issue , I am using Android Studio 3.5 stable java -version 1.8 and this is the issue : I have project [all] Flutter Android build fails with firebase dependencies. [​firebase_ml_vision] crashes after several launches on Android 5 #249. when adding the firebase_messaging: ^5.1.2 my app doesn't build, after removing it, the app builds with no problems, I tried to migrate to androidX but this didn't help, also tries to use multi dex, didn't help


write this at the bottom of app.gradle com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

Gradle Build failing after adding firebase_messaging plugin · Issue , Gradle Build failing after adding firebase_messaging plugin #37696 I only get one red error line that says: Finished with error: Gradle task assembleDebug #​3 buildApk (package:flutter_tools/src/android/apk.dart:34:9) After following https://firebase.google.com/docs/flutter/setup I have noticed the line  Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.


hello I had the same problem but I fixed it by adding in buil.gradle, I hope and solve it

dependencies {

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.0.1'
    classpath 'com.android.tools.build:gradle:3.2.1'
}

Gradle error when building Flutter apk after adding firebase, I want to implement Firebase Cloud Messaging into my Flutter application and i started to implement the Android part. I added the dependencies just like in the  Hi. I'm having the same problem as @byshy, adding fIrebase_messaging ^5.1.2 broke my app's build process, and ending up with a single line saying 'Finished with error: Gradle task assembleDebug failed with exit code 1'.


I think, when you don't have latest version of GRADLE/SDK/ANDROID STUDIO and you use the latest firebase supports version then this type of error may be generate.

Integrate a Flutter module into your Android project, Learn how to integrate a Flutter module into your existing Android project. Networking & http · JSON and serialization · Firebase · Accessibility & Do not source control the .android/ directory since it's autogenerated. Before This option allows your team to build the host app without installing the Flutter SDK. You can  Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.


Android Studio and IntelliJ, How to develop Flutter apps in Android Studio or other IntelliJ products. When creating a new app, some Flutter IDE plugins ask for an organization name in Using DevTools, a suite of debugging and profiling tools that run in a browser and The column to the far right shows how many times a widget was rebuilt since  @Xstyler85 I don't think everybody meets the problems you are describing and it should be easier. As this is getting longer and an individual support seems to be needed and this is not a bug or feature request to flutter team, please create an stackoverflow issue with some data that we can work on.


The Google Services Gradle Plugin, As part of enabling Google APIs or Firebase services in your Android application you may have to add the google-services plugin to your build.gradle file:. R8 is the new code shrinker from Google, and it’s enabled by default when you build a release APK or AAB. To disable R8, pass the --no-shrink flag to flutter build apk or flutter build appbundle. Note: Obfuscation and minification can considerably extend compile time of the Android application. Reviewing the app manifest


Distribute Android apps to testers using Gradle, You can integrate App Distribution into your Android build process using the Skip this step if you created your app after September 20, 2019: In the Google  Run your Flutter app. Go to your app's Firebase project in the Firebase console, then click Analytics in the left-nav. Click Dashboard . If Analytics is working properly, the dashboard shows an active user in the "Users active in the last 30 minutes" panel (this might take time to populate this panel).