Game Maker Firebase Crashlytics

Game Maker Firebase Crashlytics Extension provides the detailed crash reporting for your games. Firebase panel is also capable of sending you automated alerts and warnings to keep you alerted in case of increasing amount of crash reports. Well, see and feel it yourself.

Setup Firebase Tools for Game Maker Studio (Please also read “Setting Up” section below as it needs two more steps to include the library.

To be able to use the extension, you must prepare Game Maker Studio 2 to be able to compile for it. Click the link above to complete it.
For now, the extension only works at Android Exports.

Setting Up Crashlytics Library

As you setup Firebase to your project by following this tutorial, you know the locations of Android build/gradle files. So, now add the following code into the ProjectFiles\build.gradle in somewhere at the beginning of the file.

apply plugin: 'io.fabric'


By default, it should be located at C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-2.2.2.326(This depends on your Game Maker runtime version)\android\runner\ProjectFiles. The setup tutorial will give you more details about the location.

The complete file should be looking like this(Unless you have other tools, but you’ll get the idea)

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion ${YYAndroidCompileSDKVersion}
    buildToolsVersion '${YYAndroidBuildToolsVersion}'

//...
//...
//Continues and Continues

In RootFiles\build.gradle, we will add two maven repositories inside buildscript bracket.

maven { 
       url "https://maven.fabric.io/public"
 }
maven {
       url 'https://maven.google.com'
}

And also we will add Crashlytics Gradle tools inside of dependencies bracket.

classpath 'io.fabric.tools:gradle:1.26.1'

The final should be looking like this(As again, if you have other plugins etc. it may look different)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        
        mavenCentral()
		maven { 
			url "http://repo.spring.io/plugins-release/"
		}

        maven { 
            url "https://maven.fabric.io/public"
        }
        maven {
            url 'https://maven.google.com'
        }
        
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0+'
		classpath 'com.google.gms:google-services:4.0.1'
        classpath 'io.fabric.tools:gradle:1.26.1'
    }
}
allprojects {
    repositories {
        maven {
            url "https://maven.google.com"
        }
		maven { 
			url "http://repo.spring.io/plugins-release/" 
		}
        jcenter()
    }
}
Crashlytics Stack Trace Window
Crashlytics Device Information Window

DOCUMENTATION

firebase_crashlytics_enable();
Starts the crashlytics SDK. Without this function, your application does not send crash reports. Sometimes users may not give you permission to collect their crash data. This function is implemented for such cases.

firebase_crashlytics_debug_mode(True/False debugMode);
Enables debug mode. You can see what’s happening in the output console.

firebase_crashlytics_set_string(String Key, String Value);
firebase_crashlytics_set_real(String Key, Real Value);
firebase_crashlytics_set_bool(String Key, True/False debugMode);


You can include specific data to your crash reports, so that you can easily determine in which part of your game is causing the crashes.

//User logged in.
firebase_crashlytics_set_string("last_ui_action","opened_settings");

//User clicked settings button
firebase_crashlytics_set_bool("SettingsClicked", true);

///OH NO! The game is crashed here.

firebase_crashlytics_set_userid(String userID);
Sets an user ID for the crash for more personalized crash report.

firebase_crashlytics_log(String logMessage);
Logs a message, to be seen in the crash report. Can be anything…

GET THE EXTENSION
Share

Marty

Truely speaking, I don't know what am I doing most of the time.

13 Responses

  1. Chris Lee says:

    I built an extension that I use in our games which on startup parses the device log for GMS errors. Which all start with ************************* ERROR. Then you can see the actual GM code line of failure if it’s a GMS exception rather than something in an extension or some other device related failure. Perhaps there’s a way you can work with the Crashlytics extension to do something similar and parse the Log on the device for these sections of text (GMS errors) and report those. That’d make this extension invaluable!

    • Marty says:

      Hello Chris. I’d love to see and use, and of course share your extension the blog. Your extension, of course, sounds better than this one.

      This extension is integrated with other Firebase tools, so you can actually have deeper insights about what’s going on.

      Maybe I can learn something from your extension which can be used in this extension. This extension is free, open source and for the community. Would be really helpful 🙂

  2. Michail says:

    Did you test it on real in-game crashes? Doesn’t work for me. I crashed my app several times but still have 0 on dashboard. Maybe it’s just not compatible with GM stacktrace and stuff :/…

    • Yes, my game uses this extension and I receive game crash reports. (It also includes information like how much RAM the device had, OS version and some system information)

      Game Maker’s built-in crash system(FATAL ERROR messages) are not properly received by Crashlytics so you probably wouldn’t see them on Crashlytics panel.

      Once Yoyogames implement new GML update in Q4, I’ll adjust the extension accordingly.

      • Michail says:

        Yeah, that extension is kinda useless without its main feature – tracking crashes…
        Well, fine then.
        There is some info about correct crash system in Q4? Or you’re talking about try/catch block? Honestly i can’t see any possible implementation of the extension with just a “try” and “catch”… There is no way to wrap the whole code in it, you know, so we probably will never see crashlytics working, uhh…

        • We should be able to catch exceptions too. The trick is here is that we can actually log messages into the crash reports, so that we’ll have more insights and information about the crashes. The try/catch/exception etc. implementation means that Game Maker will leave its traditional FATAL MESSAGE system. All sounds okay for me.

          Also, I’ll share the Firebase Performance Monitoring extension along with it. Both works very smooth and perfectly.

  3. ENEN says:

    You are so great.
    I am saving a lot of time with your extension.

    • Marty McFly says:

      Cheers 🙂

      More extensions are on the way

      • ENEN says:

        Can not manually initialize at runtime.

        firebase_crashlytics_enable () at runtime;
        Function causes a singleton error.

        • Hi can you post the full error(output log), I’d like to check it. My game is currently using this extension and I have no issues.

          • ENEN says:

            The app used the enbled () function in the first room.

            Below is the log.

            04-18 11: 38: 20.819 25741 25841 I yoyo: Exception thrown trying to call firebase_crashlytics_enable on class gmdevbloggamemakerfirebasecrashlytics with no arguments: null
            04-18 11: 38: 20.827 25741 25841 I yoyo: InvocationTargetException thrown trying to call method firebase_crashlytics_log on gmdevbloggamemakerfirebasecrashlytics
            04-18 11: 38: 20.828 25741 25841 I yoyo: Target exception: Must initialize Fabric before using singleton (). Cause: null. Stack trace:
            04-18 11: 38: 20.828 25741 25841 I yoyo: java.lang.IllegalStateException: Must Initialize fabric before using singleton ()

          • ENEN says:

            line 39 Crashlytics.log (arg0);
            line 71 Crashlytics.setString (arg0, arg1);

            line 39 //Crashlytics.log (arg0);
            line 71 //Crashlytics.setString (arg0, arg1);

            I made this change.
            No more singleton errors.

            I do not know what the problem is.

            Anyway, after commenting, the extension works well.

            It may conflict with my other FIREBASE extensions in my app.
            I did it anyway.

          • Oh sorry. No it does not conflict with other Firebase extensions. I fixed it, now sending the patch to Marketplace.

Leave a Reply