Does Crashlytics work with Google Play Instant and if so, how do you setup your project correctly?
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:
Open the build.gradle
file in your base feature module and follow the steps on the public docs site to configure Crashlytics as normal.
At the top level of your base feature module build.gradle
file, add the following Crashlytics flag:
...
android {
...
}
crashlytics { instantAppSupport true }
...
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.
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.