Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Crashlytics for mobile apps in Qt
Forum Updated to NodeBB v4.3 + New Features

Crashlytics for mobile apps in Qt

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 1 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SyntaXS Offline
    SyntaXS Offline
    SyntaX
    wrote on last edited by
    #1

    Hey there :D

    I wanted to add Crashlytics to my Qt Project (for now only for Android) but stumbled across some issues :/

    Seems like, I am not the first one having troubles,
    but I didn't manage to find a solution that works :/

    @RonaldoD I found your post, back from 2015. I know, that's a little outdated, but I was wondering, if you have some useful hints? Sadly, the website I not available anymore :(
    Re: Integrate Qt Android Application with Crashlytics Tools

    What I managed so far, was the integration of the Firebase Crashlytics SDK from google (not the "old" Fabric SDK)
    for the native android java side, essential code below:

    build.gradle
    
    ...
    apply plugin: 'com.google.firebase.crashlytics'
    
    dependencies {
        ...
        // Add the Firebase SDK for Crashlytics.
        //implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' // old fabric
        implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta03'
    
        // Add the Crashlytics NDK dependency.
        //implementation 'com.google.firebase:firebase-crashlytics-ndk:17.0.0-beta03'
    

    which seems to work for exceptions and logging on the android side

    mFirebaseCrashlytics.log("crashing!"); // log error
    
    try {
        throw new RuntimeException("Test Crash");
    } catch (Exception exc) {
        mFirebaseCrashlytics.recordException(exc); // capture Android stack trace
    }
    

    But if the App really crashes, it seems that there is no stack trace available in my Crashlytics reports.
    Application output from Qt Creator is something like this

    #30 pc 0023c840  /data/app/com.test.app-RkCEhhQMFtPWdUreXh90mw==/lib/x86/libQt5Core_x86.so (void QJNIObjectPrivate::callStaticMethodV<void>(_jclass*, char const*, char const*, char*)+72)
    #31 pc 0023c8be  /data/app/com.test.app-RkCEhhQMFtPWdUreXh90mw==/lib/x86/libQt5Core_x86.so (void QJNIObjectPrivate::callStaticMethod<void>(_jclass*, char const*, char const*, ...)+58)
    #32 pc 00023b50  /data/app/com.test.app-RkCEhhQMFtPWdUreXh90mw==/lib/x86/libplugins_platforms_qtforandroid_x86.so (???)
    
    No pending exception expected: java.lang.RuntimeException: forced runtime exception
    at void com.test.app.MyApp.testCrash() (myapp.java:85)
    

    I am not really familiar with the Qt / depending mobile platform build systems,
    but I assume I need to add the Crashlytics NDK to be able to capture the cpp/Qt stack trace?

    But as soon, as I am adding :firebase-crashlytics-ndk:17.0.0-beta03 in the Gradle dependencies, my app crashes at startup:

    I System.out: java: 15:26:50.GMT+02:00 > Android onCreate() hit in myActivity.java
    W System  : ClassLoader referenced unknown path:
    W System.err: java.lang.ClassNotFoundException: Didn't find class "org.qtproject.qt5.android.QtActivityDelegate" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /system/product/lib]]
    W System.err: 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
    W System.err: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    ...
    W System.err: 	at com.test.app.myActivity.onCreate(:61)
    

    Following the guidelines from https://firebase.google.com/docs/crashlytics/ndk-reports-new-sdk I found that I need to

    • Run the following NDK-specific Gradle tasks:
      ./gradlew app:assembleBUILD_VARIANT
      ./gradlew app:uploadCrashlyticsSymbolFileBUILD_VARIANT

    But I do not know, where / when to put these?

    Also I don't really understand

    Step 3 (optional): Upload symbols for external dependencies

    What are "stripped libraries", how do I know which I need and where to find them?

    Is there anyone with more experience, who can help me with this topic? :D
    Any help is appreciated!

    best Regards
    SyntaX

    1 Reply Last reply
    1
    • SyntaXS Offline
      SyntaXS Offline
      SyntaX
      wrote on last edited by
      #2

      ok, still don't know what exactly are unstripped / stripped libs are,
      but I managed to get basic NDK reports running :D

      the mentioned gradlew app:uploadCrashlyticsSymbol goes into the build.gradle file within the android tag:

      afterEvaluate {
          assembleRelease.finalizedBy(uploadCrashlyticsSymbolFileRelease)
      }
      

      other settings can be taken from the official sdk documentation found here
      https://firebase.google.com/docs/crashlytics/ndk-reports-new-sdk

      1 Reply Last reply
      1
      • SyntaXS Offline
        SyntaXS Offline
        SyntaX
        wrote on last edited by
        #3

        I managed to achieve one step further to my goal :D

        The 'libs' folder is generated during compilation, which contains the depending .so files,
        which I was able to include with relative paths, from the build directory:

        buildTypes {
                //debug
                release {
                    // When minifyEnabled is set to true, Crashlytics automatically
                    // uploads mapping files because the plugin detects that obfuscation
                    // is enabled. mappingFileUploadEnabled defaults to true if
                    // minifyEnabled is true.
                    minifyEnabled true
                    firebaseCrashlytics {
                        //mappingFileUploadEnabled true
        
                        // Enable processing and uploading of native symbols to Crashlytics
                        // servers. By default, this is disabled to improve build speeds.
                        // This flag must be enabled to see properly-symbolicated native
                        // stack traces in the Crashlytics dashboard.
                        nativeSymbolUploadEnabled true
                        strippedNativeLibsDir '/libs'
                        unstrippedNativeLibsDir '/libs'
                    }
                }
            }
        

        Although the full compilation now takes about 28 minutes on my machine, at least I am able to compile and deploy the application on my test devices (Emulator and Nexus 10 :D)

        But if I open the application on my device, it immediately crashes xD

        D/libcrashlytics(19474): Initializing native crash handling successful.
        I/FirebaseCrashlytics(19474): Crashlytics NDK initialization successful
        ...
        W/System.err(19474): java.lang.ClassNotFoundException: Didn't find class "org.qtproject.qt5.android.QtActivityDelegate" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
        W/System.err(19474): 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        W/System.err(19474): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        W/System.err(19474): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        ...
        
        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved