How do I integrate Crashlytics with Android Instant Apps?

*爱你&永不变心* 提交于 2019-12-17 12:15:24

问题


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


回答1:


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.




回答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' }
}



回答3:


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.



来源:https://stackoverflow.com/questions/44361850/how-do-i-integrate-crashlytics-with-android-instant-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!