How do I integrate Crashlytics with Android Instant Apps?
Asked Answered
P

3

19

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

Psychosis answered 5/6, 2017 at 4:50 Comment(0)
P
21

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.

Psychosis answered 5/6, 2017 at 4:50 Comment(8)
To use compile 'com.google.android.instantapps:instantapps:1.0.0' Don't forget to add: maven { url 'maven.google.com' } to the repositoriesOgre
Thanks @LorenzoValentijn, i added a note in the answer.Psychosis
After following all this steps my Instant app crashes on start with 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. errorFisk
It seems there is a bug in recent versions of Instant Apps / Studio that is stripping out the generated Crashlytics key from the generated APKs. Until that's fixed, try this as a workaround. After building, find the file "com_crashlytics_build_id.xml", open it up, copy the <string /> from there and paste it into your strings.xml file for your feature module. Re-build and run.Psychosis
The String copy works (at least no compilation error), but whenever clean the project, it always complaints duplicate resources :(Christen
FYI, issue should be fixed now, I have updated the answer as well.Psychosis
I have configures crashlytics in InstantApp. I can not see crashes in fabrics console. I tried copying string file from "com_crashlytics_build_id.xml". It is telling dublicate resource. I deleted build folder/clean/rebuild. Not working...:(Sulk
I think this is not supported anymore, after moving to Firebase: github.com/firebase/firebase-android-sdk/issues/…Entrain
D
2

Besides what the accepted answer says, I also needed to add the next lines at the build.gradle file of the application (apk) module to get it running.

repositories {
    maven { url 'https://maven.fabric.io/public' }
}
Declinate answered 19/7, 2017 at 14:21 Comment(0)
G
0

I just tested with 1.24.5 and it was fine.

I was able to setup my project like this:

  1. in base module: https://fabric.io/kits/android/crashlytics/install
  2. How do I integrate Crashlytics with Android Instant Apps?
    • add to base/build.gradle:
      • crashlytics { instantAppSupport true }
      • compile 'com.google.android.instantapps:instantapps:1.1.0' (*1.0.0 also works)
    • additionally add to the base module Application class:
      • Crashlytics.setBool("InstantApp", InstantApps.isInstantApp(context));

My test instant app built, I triggered a crash, and my dashboard logged it.

If any issue persists, please report at Google issue tracker they will re-open to examine.

Gesticulative answered 16/12, 2017 at 6:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.