Jiri Zaloudek
Jiri Zaloudek

Reputation: 71

how to include Firebase Crashlytics in this setup?

this is how my build.gradle looks in order to use firebase c++ sdk for analytics and messaging... I also want to include crashlytics in order to see why app crashes in Firebase console (I cant find any info about crashed just by using Analytics):

buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.6.0'                            // Notice the 8.6 version here, not sure why but seems we always need to be one version less than what we updated
        classpath 'com.google.gms:google-services:4.4.2'                            // Google Services plugin
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'           // Crashlytics
        
        def firebase_cpp_sdk_dir = System.getProperty('firebase_cpp_sdk.dir')       // the lines below won't need to be changed later as the path is read from gradle.properties
        
        gradle.ext.firebase_cpp_sdk_dir = "$firebase_cpp_sdk_dir"
        apply from: "$firebase_cpp_sdk_dir/Android/firebase_dependencies.gradle"
    }
}

repositories {
    google()
    mavenCentral()
}

apply plugin: qtGradlePluginType
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'                                      // Google Services plugin
apply plugin: 'com.google.firebase.crashlytics'                                     // Crashlytics


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    implementation 'androidx.core:core:1.13.1'
}

android {
    /*******************************************************
     * The following variables:
     * - androidBuildToolsVersion,
     * - androidCompileSdkVersion
     * - qtAndroidDir - holds the path to qt android files
     *                   needed to build any Qt application
     *                   on Android.
     * - qtGradlePluginType - whether to build an app or a library
     *
     * are defined in gradle.properties file. This file is
     * updated by QtCreator and androiddeployqt tools.
     * Changing them manually might break the compilation!
     *******************************************************/

    namespace androidPackageName
    compileSdkVersion androidCompileSdkVersion
    buildToolsVersion androidBuildToolsVersion
    ndkVersion androidNdkVersion

    // Extract native libraries from the APK
    packagingOptions.jniLibs.useLegacyPackaging true

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = [qtAndroidDir + '/src', 'src', 'java']
            aidl.srcDirs = [qtAndroidDir + '/src', 'src', 'aidl']
            res.srcDirs = [qtAndroidDir + '/res', 'res']
            resources.srcDirs = ['resources']
            renderscript.srcDirs = ['src']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
       }
    }

    tasks.withType(JavaCompile) {
        options.incremental = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        abortOnError false
    }

    // Do not compress Qt binary resources file
    aaptOptions {
        noCompress 'rcc'
    }

    defaultConfig {
        resConfig "en"
        minSdkVersion qtMinSdkVersion
        targetSdkVersion qtTargetSdkVersion
        ndk.abiFilters = qtTargetAbiList.split(",")
        ndk.debugSymbolLevel "FULL"
    }
}


// You must put here all modules you want from firebase
firebaseCpp.dependencies {
    analytics
    messaging
    crashlytics
}
  1. I have added:

    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'

not sure why this 2.9.9 version, just googled up

  1. also added:

    apply plugin: 'com.google.firebase.crashlytics'

not sure if this should I do, however no error generated from this

  1. also added to firebaseCpp.dependencies:

    crashlytics

but basicaly only the point 3 generates error: Could not get unknown property 'crashlytics' for object of type Dependencies.

the list od dependencis it actually uses from firebase_cpp_sdk/Android/firebase_dependencies.gradle where you can see amoung all possibilities analytics, messaging but not crashlytics

so to my question is... form the way I have used my build.gradle, how do I add the crashlytics?

EDIT: just removing crashlytics from dependencies starts app without any issue. When app starts and crash is simulated (triggered by qFatal(), however in Firebase console neither Google Analytics console I can find any info about this crash or I dont know where... Crashlytics tab still shows initial screen to include sdk: enter image description here

Upvotes: 0

Views: 46

Answers (0)

Related Questions