Home:ALL Converter>Fabric / Firebase integration in Unity

Fabric / Firebase integration in Unity

Ask Time:2017-11-25T07:02:45         Author:Frank Servy

Json Formatter

I am having difficulties with integrating Firebase and Fabric in my Unity project. I have eventually managed to get them to work together by installing the Firebase plugin then the Fabric plugin (it never worked the other way round). The issue is that I only see Firebase events in my Firebase console and no Fabric/Answers events (which I can see in Fabric so I know that there are events fired).

Question1: I am using Unity to generate my APK, could it be the issue and should I use Android Studio with gradle?

Question2: I have tried to build my app in Android Studio with gradle but I get an error when I start my app:

Didn't find class "io.fabric.unity.android.FabricApplication" on path: DexPathList[[zip file "/data/app/com.domain.appname-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.domain.appname-1, /vendor/lib, /system/lib]]

As I am new to gradle, what is a correct gradle for such a project (ie Unity with Firebase and Fabric)?

For information my build.gradle looks like this:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.1'
    }
}

allprojects {
   repositories {
       maven { url 'https://maven.google.com' }
      flatDir {
        dirs 'libs'
      }
   }
}

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.firebase:firebase-core:11.4.2'
    compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true
    }
}

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    defaultConfig {
        targetSdkVersion 25
        applicationId 'com.domain.appname'
    }

    lintOptions {
        abortOnError false
    }
    signingConfigs { release {
        storeFile file('xxxxx')
        storePassword 'xxxxxx'
        keyAlias 'xxxxxx'
        keyPassword 'xxxxxx'
    } }

    buildTypes {
        debug {
            jniDebuggable true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
            signingConfig signingConfigs.release
        }
    }

}

apply plugin: 'com.google.gms.google-services'

UPDATE 1: I went through the process one more time and now found an error in Fabric console under Tools->Firebase saying that my Crashlytics SDK is not up to date. Crashlytics SDK is not up to date

I have reinstalled the latest Fabric/Crashlytics Unity plugin from Fabric for Unity plugin. In Unity it shows up as Crashlytics v1.2.5 which is the latest version indicated on Fabric: Fabric changelog

This is when I am now wondering if by using gradle I would be able to somehow update my Fabric SDK.

Author:Frank Servy,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/47481005/fabric-firebase-integration-in-unity
yy