3

I am not experienced in flutter but been doing it for a while. My current project is using firebase so I'm using flutterfire package and it has to be my worst nightmare so far. Build fail upon build fail. Note IOS is working though. The recent is this

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':firebase_crashlytics:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':firebase_crashlytics:debugCompileClasspath'.
   > Could not find com.google.firebase:firebase-crashlytics:.
     Required by:
         project :firebase_crashlytics

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1

android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    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.4"
        classpath "com.google.firebase:firebase-crashlytics-gradle:2.3.0"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}

subprojects {
    project.evaluationDependsOn(':app')
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
        }
    }
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'androidx.core' &&
                    !details.requested.name.contains('androidx')) {
                details.useVersion "1.0.1"
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

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

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 plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'


android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28
        multiDexEnabled true
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.tendo.app"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    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
        }
    }
}

rootProject.ext {
  set('FlutterFire', [
    FirebaseSDKVersion: '21.1.0'
  ])
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
    implementation platform('com.google.firebase:firebase-bom:25.12.0')
}

3 Answers 3

2

You need to implement the dependencies in app-level gradle file app/build.gradle

// Add the Firebase Crashlytics SDK.
    implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
    // Recommended: Add the Google Analytics SDK.
    implementation 'com.google.firebase:firebase-analytics:18.0.0'

The dependencies section should look like this

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
    // Add the Firebase Crashlytics SDK.
    implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
    // Recommended: Add the Google Analytics SDK.
    implementation 'com.google.firebase:firebase-analytics:18.0.0'
}

I hope this will fix your issue.

3
  • I also would like to recommend you to follow this Initialize Crashlytics to specific dependencies setup for Java / Kotlin
    – dipakbari4
    Nov 3, 2020 at 7:29
  • I tried it and I just did this and still same build failure and same message :(
    – Quajo Duke
    Nov 3, 2020 at 7:39
  • I've update the code. Once try to update in your code. Hope this will work.
    – dipakbari4
    Nov 3, 2020 at 16:28
1

try changing the version in android/build.gradle:

    classpath 'com.google.gms:google-services:4.3.3'
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'

I hope I've helped

1
  • I have done that over and over the current version you are seeing is what i got from the official doc of firebase. I know this version is from the docs from fluttterfire. Yet still i tried your answer and still build fail :(
    – Quajo Duke
    Nov 3, 2020 at 7:01
0

It is necessary to check the use of the setCrashlyticsCollectionEnabled, because if you disabled the crash collection setCrashlyticsCollectionEnabled(false) and then if later you want to enable it, just commenting out the above line DOES NOT automatically start the collection process if the app has already been installed with 'false' flag before, so setCrashlyticsCollectionEnabled(true) needs to be explicitly called again.

But for me the problem was exactly in setCrashlyticsCollectionEnabled(true), I called it every start, so I comment it out, and error disappeared.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.