1

I am trying to get Crashlytics reports from simple insant app. The app has one activity with one button to generate crash. Му MainActivity code is:

package com.example.instantcrashtest;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import com.google.android.gms.common.wrappers.InstantApps;
import com.google.firebase.crashlytics.FirebaseCrashlytics;

public class MainActivity extends AppCompatActivity {


    private FirebaseCrashlytics mCrashlytics;

    void makeCrash()
    {
        throw new RuntimeException("Test Crash INST V34"); // Force a crash
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                makeCrash();
            }
        });

        mCrashlytics = FirebaseCrashlytics.getInstance();

        // Add some custom values and identifiers to be included in crash reports
        mCrashlytics.setCustomKey("InstantApp", InstantApps.isInstantApp(getApplicationContext()));
     }
}

My root project gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"


        // Add this line
        classpath 'com.google.gms:google-services:4.3.10'

        // Add the Crashlytics Gradle plugin
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

My base module gradle file:

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

// Apply the Crashlytics Gradle plugin
apply plugin: 'com.google.firebase.crashlytics'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.instantcrashtest"
        minSdkVersion 26
        targetSdkVersion 30
        versionCode 7
        versionName "7.instant"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}


dependencies {

    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'


    implementation "com.google.android.gms:play-services-instantapps:17.0.0"

    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:28.4.2')

    // Declare the dependencies for the Crashlytics and Analytics libraries
    // When using the BoM, you don't specify versions in Firebase library dependencies
    
    implementation 'com.google.firebase:firebase-crashlytics'
    implementation 'com.google.firebase:firebase-analytics'
}

Manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution"
    package="com.example.instantcrashtest"
    android:targetSandboxVersion="2">

    <dist:module dist:instant="true" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.InstantCrashTest"
        android:networkSecurityConfig="@xml/network_security_config">

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

When run the app as common app, everything works fine. When running as instant app, google analytics works and shows number of crashes, but in crashlytics there are no new crashes.

The log file:

roman@roman-X:/media/roman/ADATA/Android/Sdk/platform-tools$ ./adb logcat -s FirebaseCrashlytics

10-25 14:03:04.798  2427  2427 I FirebaseCrashlytics: Initializing Firebase Crashlytics 18.2.3 for com.example.instantcrashtest
10-25 14:03:04.810  2427  2427 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API.
10-25 14:03:04.819  2427  2427 D FirebaseCrashlytics: AnalyticsConnector now available.
10-25 14:03:04.824  2427  2427 D FirebaseCrashlytics: Registered Firebase Analytics listener.
10-25 14:03:04.829  2427  2427 D FirebaseCrashlytics: Mapping file ID is: 00000000000000000000000000000000
10-25 14:03:04.888  2427  2427 D FirebaseCrashlytics: Checking for cached settings...
10-25 14:03:04.898  2427  2427 D FirebaseCrashlytics: Loaded cached settings: {"settings_version":3,"cache_duration":86400,"features":{"collect_logged_exceptions":true,"collect_reports":true,"collect_analytics":false,"prompt_enabled":false,"push_enabled":false,"firebase_crashlytics_enabled":false,"collect_anrs":false,"collect_metric_kit":false},"app":{"status":"activated","update_required":false,"report_upload_variant":2,"native_report_upload_variant":2},"fabric":{"org_id":"617451c02a6b5fc1656188e4","bundle_id":"com.example.instantcrashtest"},"expires_at":1635244454191}
10-25 14:03:04.974  2427  2427 D FirebaseCrashlytics: Successfully configured exception handler.
10-25 14:03:04.975  2427  2675 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API.
10-25 14:03:04.989  2427  2675 D FirebaseCrashlytics: Opening a new session with ID 61768EE803CE0001097B4F09702B2F67
10-25 14:03:05.022  2427  2675 D FirebaseCrashlytics: Registered Firebase Analytics event receiver for breadcrumbs
10-25 14:03:05.576  2427  2427 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API.

// here I generate test crash

10-25 14:03:16.477  2427  2427 D FirebaseCrashlytics: Handling uncaught exception "java.lang.RuntimeException: Test Crash INST V34" from thread main
10-25 14:03:16.643  2427  2675 D FirebaseCrashlytics: Opening a new session with ID 61768EF402810002097B4F09702B2F67
10-25 14:03:16.652  2427  2675 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API.
10-25 14:03:16.655  2427  2675 D FirebaseCrashlytics: Logging app exception event to Firebase Analytics
10-25 14:03:16.795  2427  2675 D FirebaseCrashlytics: Crashlytics report successfully enqueued to DataTransport: 61768EE803CE0001097B4F09702B2F67
10-25 14:03:16.796  2427  2427 D FirebaseCrashlytics: Completed exception processing. Invoking default exception handler.

It seems that the crash report is generated in both modes (normal, instant). But in instant mode it is not sent to the server.

Is it possible to fix this problem, or may be, crashlytics is not supported in insant apps? Thanks.

  • Same issue :(, tested with Instant App installation from Android Studio and Instant app from the Google Play with the option "Try now". – Akhha8 Feb 03 '22 at 18:10
  • I discussed this issue with their techsupprt at november. After a week of torture (they even readdressed the issue to their enjineering team), they confessed that "instant apps are not supported now"))) – Roman Kononenko Feb 09 '22 at 19:35

0 Answers0