如何将Crashlytics与Android Instant Apps集成?

问题描述 投票:17回答:3

Crashlytics是否与Android Instant Apps合作?如果是,您如何正确设置项目?

android crashlytics twitter-fabric android-instant-apps
3个回答
21
投票

是的,Crashlytics确实与Android Instant Apps配合使用,实际上它是此阶段推荐的崩溃报告解决方案,因为它已经过测试并且运行正常。

对于设置:

Step 1

打开基本功能模块中的build.gradle文件,然后按照public docs site上的步骤正常配置Crashlytics。

Step 2

在基本功能模块build.gradle文件的顶层,添加以下Crashlytics标志:

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

Step 3 (optional but recommended)

根据build.gradle,在基础库项目docs中添加Instant App库依赖项(如果尚未存在):

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

注意:要使用此依赖项,您需要将新的maven.google.com存储库添加到gradle文件中(如果尚未添加)(有关详细信息,请参阅here)。

然后在您的代码中,在设置Crashlytics之后,如果当前运行是Instant App,则设置一个布尔值来记录:

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

截至2017年8月更新 - 破坏支持的新问题 最近的工具更新似乎在使用Crashlytics和Instant Apps时导致new issue记录以下错误:

这个应用程序依赖于Crashlytics。请在https://fabric.io/sign_up注册访问,安装Android构建工具并要求团队成员邀请您加入此应用程序的组织。

在问题解决之前,请尝试将其作为解决方法:在构建之后,找到文件com_crashlytics_build_id.xml,打开它,从包含Fabric键的那里复制<string>并将其粘贴到您的功能模块的正常strings.xml文件中。然后重新构建并运行。

Update as of Nov 15, 2017 - Issue fixed

上面的问题现在从Fabric gradle插件v1.24.5开始修复。您的gradle文件应具有:

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

您不需要做任何事情,只需同步您的构建以通过修复下载更新的插件。


2
投票

除了接受的答案之外,我还需要在应用程序(apk)模块的build.gradle文件中添加下一行以使其运行。

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

0
投票

我刚用1.24.5进行测试,很好。

我能够像这样设置我的项目:

  1. 在基础模块:https://fabric.io/kits/android/crashlytics/install
  2. How do I integrate Crashlytics with Android Instant Apps? 添加到base / build.gradle: crashlytics {instantAppSupport true} 编译'com.google.android.instantapps:instantapps:1.1.0'(* 1.0.0也可以) 另外添加到基础模块Application类: Crashlytics.setBool(“InstantApp”,InstantApps.isInstantApp(context));

我的测试即时应用程序构建,我触发了崩溃,我的仪表板记录了它。

如果任何问题仍然存在,请在Google issue tracker报告,他们将重新开放审查。

© www.soinside.com 2019 - 2024. All rights reserved.