0

Getting the following error while trying to run new flutter app with Firebase

Error running Gradle:
ProcessException: Process "...\gradlew.bat" exited abnormally:

I have followed instructions at https://firebase.google.com/docs/flutter/setup to the letter.

google-services.json is at android/app folder

in app/build.gradle i have

buildscript {
ext.kotlin_version = '1.2.71'
repositories {
    google()
    jcenter()
    maven { url 'https://maven.google.com' }
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.2'
}

}

and in project build.gradle dependencies

    implementation 'com.google.firebase:firebase-analytics:17.2.0'

and at the bottom

apply plugin: 'com.google.gms.google-services'  // Google Play services Gradle plugin

pubspec.yaml has

  firebase_core: ^0.4.0+9

The app is registered with correct name at Firebase console as android app.

  • I tried with different versions of com.android.tools.build:gradle and com.google.gms:google-services
  • flutter doctor shows no errors
  • I deleted user/.gradle/caches/ folders

1 Answer 1

0

Based on @Maadhav-Sharma's answer i got it working with following fixes. Problems is with AndroidX compatibility even for new Flutter projects with compileSdkVersion 28 that should AndroiX compatible. More info: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility

Make a new project first.

In android/build.gradle:

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

In android/gradle/wrapper/gradle.properties, append

android.enableJetifier=true
android.useAndroidX=true

In android/app/build.gradle:

defaultConfig {


    minSdkVersion 16
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    multiDexEnabled true // This was needed to get FireStore to work
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation 'androidx.multidex:multidex:2.0.1' // This was needed to get FireStore to work

}
apply plugin: 'com.google.gms.google-services'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.