1

I m implementing and InstantApp in which I added FirebaseCrash.

I follow all the steps to set it up and when I run the app using the build configuration for the installable version it works like a charm but when I try to run the build configuration for the InstantApp FirebaseCrash is crashing the app.

The app crash in this line where I am emulating a crash just to check if it works:

FirebaseCrash.logcat(Log.ERROR, "Firebase", "I am broken!!");

This is the crash when I run it for the InstantApp:

Process: uk.co.alpha.test.app, PID: 3516                                               
java.lang.RuntimeException: Unable to start activity 
ComponentInfo{[package.class]}: java.lang.IllegalStateException: 
Default FirebaseApp is not initialized in this process [package] Make 
sure to call FirebaseApp.initializeApp(Context) first.

I tried adding FirebaseApp.initializeApp(Context) in the onCreate of the class where it is crashing and I also try adding it in the class that extends from Application but the same crash appears.

I check stackoverflow and the official Firebase documentation and I didnt find anything specific for InstantApps

It works for the installable version but I added my gradle files just in case it can help to solve it:

./build.gradle

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.google.com'}
        //Dexcount Gradle Plugin
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.0.0'
        //Dexcount Gradle Plugin
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.0-SNAPSHOT'
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.google.com' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

ext {
    buildTools = '25.0.2'
    compileSdk = 25
    minSdk = 23
    versionCode = 11
    versionName = '4.0'
    supportLib = '25.3.1'
    playServices = "11.0.0"
}

features/build.gradle

buildscript {
    repositories {
        jcenter()
    }
}
apply plugin: 'com.android.feature'

repositories {
    jcenter()
    mavenCentral()
}

android {
    compileSdkVersion rootProject.compileSdk
    buildToolsVersion rootProject.buildTools

    baseFeature true
    defaultConfig {
        minSdkVersion rootProject.minSdk
        targetSdkVersion rootProject.compileSdk
        versionCode rootProject.versionCode
        versionName rootProject.versionName
    }

    compileOptions {
    targetCompatibility JavaVersion.VERSION_1_8
    sourceCompatibility JavaVersion.VERSION_1_8
}

signingConfigs {
    release {
        storeFile file("instantApp_keystore")
        storePassword "..."
        keyAlias "..."
        keyPassword "..."
    }
}

buildTypes {
    debug {
        buildConfigField "String", "PARSE_BACKUP", "\"" + PARSE_BACKUP + "\""
        buildConfigField "String", "PARSE", "\"" + PARSE_LIVE + "\""
        buildConfigField "String", "PARSE_APP_ID", "\"" + parseAppId_LIVE + "\""
        buildConfigField "String", "PARSE_CLIENT_KEY", "\"" + parseClientKey_LIVE + "\""
    }
    release {
        signingConfig signingConfigs.release
        buildConfigField "String", "PARSE_BACKUP", "\"" + PARSE_BACKUP + "\""
        buildConfigField "String", "PARSE", "\"" + PARSE_LIVE + "\""
        buildConfigField "String", "PARSE_APP_ID", "\"" + parseAppId_LIVE + "\""
        buildConfigField "String", "PARSE_CLIENT_KEY", "\"" + parseClientKey_LIVE + "\""
    }
}

packagingOptions {
    exclude 'META-INF/rxjava.properties'
}
}

dependencies {
    compile "com.android.support:appcompat-v7:${rootProject.supportLib}"
    compile "com.android.support:design:${rootProject.supportLib}"
    compile "com.google.android.gms:play-services-analytics:${rootProject.playServices}"

    compile 'com.parse:parse-android:1.14.1'
    compile 'com.squareup:otto:1.3.8'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile ('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2'){
        exclude module: 'support-v4'
    }
    compile 'me.relex:circleindicator:1.2.2@aar'
    compile 'com.squareup.picasso:picasso:2.5.2'

    compile "com.google.firebase:firebase-crash:${rootProject.playServices}"
}
apply plugin: 'com.google.gms.google-services'

Thanks in advance!!!! ;)

  • Here is a list of libraries compatible with instant apps: https://developer.android.com/topic/instant-apps/prepare.html#identify_tested_compatible_libraries – ManmeetP Oct 27 '17 at 04:29

1 Answers1

2

Unfortunately Firebase Crash Reporting does not work with Instant Apps nor are there plans to specifically update it to work with Instant Apps. This is because Fabric is now part of the Firebase team, Fabric Crashlytics is where future effort will be spent. The Firebase docs mention this as well.

Crashlytics already works with Instant Apps, see this post for information on setting it up:

How do I integrate Crashlytics with Android Instant Apps?

AdamK
  • 21,199
  • 5
  • 42
  • 58