android firebase crashlytics Cannot invoke method all() on null object

Viewed 156

i've implemented firebase crashlytics as documented on it's official website. But when i build my project i get an error below:

* What went wrong:
A problem occurred configuring project ':app'.
> Cannot invoke method all() on null object

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

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app’

Caused by: java.lang.NullPointerException: Cannot invoke method all() on null object
    at com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsPlugin$_apply_closure1$_closure10.doCall(CrashlyticsPlugin.groovy:91)

at jdk.internal.reflect.GeneratedMethodAccessor786.invoke(Unknown Source)

Here are my implementation versions :

build.gradle (project)

dependencies {
    classpath "com.android.tools.build:gradle:7.1.3"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20"
    classpath "com.google.dagger:hilt-android-gradle-plugin:2.41"
    classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.2"
    classpath "com.google.gms:google-services:4.3.10"
    classpath "com.google.firebase:firebase-crashlytics-gradle:2.8.1"
}

build.gradle (app)


plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id "kotlin-kapt"
    id "dagger.hilt.android.plugin"
    id 'androidx.navigation.safeargs.kotlin'
    id "com.google.gms.google-services"
    id 'com.google.firebase.crashlytics'
}

dependencies {
    implementation platform("com.google.firebase:firebase-bom:30.0.2")
    implementation "com.google.firebase:firebase-analytics-ktx"
    implementation "com.google.firebase:firebase-crashlytics-ktx"
}

i've placed my google-services.json file under "app" folder.

i couldn't figure out why this error occurs.

1 Answers

In the project all the dependency versions was separated and kept on different file which is called versions.gradle.

it turns out that problem occurs from that file.

def app_version = [:]
app_version.major = 1
app_version.minor = 0
app_version.patch = 0
app_version.classifier = null  // like "ALPHA" - "BETA"
app_version.is_snapshot = false
ext.app_version = app_version

That was an example of the versions.gradle file content

But that map declaration is causing error on gradle side. We changed the file content like below and problem solved.

ext.appInfo = [
    appVersionMajor         : 1,
    appVersionMinor         : 0,
    appVersionPatch         : 0,
    appVersionClassifier    : null,
    appVersionIsSnapshot    : false
]
Related