How to Add Multiple Gradle Dependencies (Project & App Level) in a Defold Native Extension for Firebase Crashlytics?

I’m working on integrating Firebase Crashlyticsinto my Defold project using a custom native extension. According to the official Firebase Crashlytics setup guide, we need to add dependencies and plugins to both the project-level and app-level build.gradle files, like so:

Project-level build.gradle

buildscript {
    dependencies {
        classpath 'com.google.firebase:firebase-crashlytics-gradle:<latest-version>'
    }
}

App level build.gradle:

plugins {
    id 'com.google.firebase.crashlytics'
}

dependencies {
    implementation 'com.google.firebase:firebase-crashlytics'
}

However, Defold’s native extension format only allows specifying one build.gradle per extension (usually in the upload/ folder), and I can’t seem to control or inject code into both the project and app level build.gradle files.

My Question

  1. How can I inject dependencies into both the root and app-level build.gradle files through a native extension in Defold?
  2. Is there a supported or recommended way to apply the Crashlytics Gradle plugin inside a Defold native extension, or any known workarounds?

We only use gradle to resolve dependencies. The rest of the build is done without using gradle. I’m not sure what the purpose of the crashlytics gradle plugin is, but it will be ignored. This may or may not be a problem, depending on what it actually does. Do you know?

I’m trying to use Crashlytics to get stack traces for native crashes. According to the Crashlytics documentation, I need to add the following to my app-level build.gradle file:

buildTypes {
    release {
        firebaseCrashlytics {
            nativeSymbolUploadEnabled true
        }
    }
}

But for this to work, I also need to apply the plugin:

plugins {
    id 'com.google.firebase.crashlytics'

}

As you said that the plugins section will be ignored , then the firebaseCrashlytics { ... } block causes a build error because it’s not recognized. And if I don’t include the {...} block, Crashlytics won’t upload native crash stack traces properly.

Are you sure about this? My guess is that the plugin adds a service or something to check for unsent crashes and send those automatically. You should be able to do that from your Defold extension using the Crashlytics API: