Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I integrate Crashlytics with Android Instant Apps?

Does Crashlytics work with Google Play Instant and if so, how do you setup your project correctly?

like image 297
AdamK Avatar asked Jun 05 '17 04:06

AdamK


1 Answers

Yes, Crashlytics does work with Android Instant Apps, in fact it is the recommended crash reporting solution at this stage as it has been tested and works fine.

For setup:

Step 1

Open the build.gradle file in your base feature module and follow the steps on the public docs site to configure Crashlytics as normal.

Step 2

At the top level of your base feature module build.gradle file, add the following Crashlytics flag:

...
android {
    ...
}
crashlytics { instantAppSupport true }
...

Step 3 (optional but recommended)

Add the Instant App library dependency in your base library project build.gradle if not already there as per the docs:

compile 'com.google.android.instantapps:instantapps:1.1.0'

Note: to use this dependency you will need to add the newer maven.google.com repository to your gradle files if you haven't already (see here for details).

Then in your code, after setting up Crashlytics, set a boolean value to log if the current run is an Instant App:

Crashlytics.setBool("InstantApp", InstantApps.isInstantApp(context));

Update as of Aug 2017 - New issue that breaks support

A recent tools update seems to have caused a new issue when using Crashlytics and Instant Apps that logs the following error:

This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up, install an Android build tool and ask a team member to invite you to this app's organization.

Until the issue is fixed, please try this as a workaround: after building, find the file com_crashlytics_build_id.xml, open it up, copy the <string> from there that contains your Fabric key and paste it into your normal strings.xml file for your feature module. Then re-build and run.

Update as of Nov 15, 2017 - Issue fixed

The issue above is now fixed as of Fabric gradle plugin v1.24.5. As your gradle file should have:

classpath 'io.fabric.tools:gradle:1.+'

You shouldn't need to do anything but sync up your build to pull down the updated plugin with fix.

like image 167
AdamK Avatar answered Nov 08 '22 05:11

AdamK