Crash reports with Crashlytics
When releasing to the Play Store, you build a release version of the APK, stripped of all debugging information. So if a crash happens, there is no way to connect to the phone over adb and get system logs. The solution is to use a library that catches those exceptions and sends them to a server. We will use Crashlytics by Fabric. Firebase also has its own solution, but it is being replaced by Crashlytics. The process is simple so this post will be short:
- Create an account
- Get the Fabric plugin for Android Studio.
- Then I got an error saying that firebase-ui-auth already set up a fabric api key, and suggests a way to override that value.
Error:Execution failed for task ':app:processDebugManifest'. > Manifest merger failed : Attribute meta-data#io.fabric.ApiKey@value value=(...) from AndroidManifest.xml:40:13-69 is also present at [com.firebaseui:firebase-ui-auth:2.3.0] AndroidManifest.xml:21:13-60 value=(@string/twitter_consumer_secret). Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:38:9-40:72 to override.
- In order to use
tools:replace, I had to add the tools namespace. The changes to the manifest look like this:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.wafrat.rappel"> ... <application ...> ... <meta-data android:name="io.fabric.ApiKey" android:value="..." tools:replace="android:value" /> </application> </manifest>
- Then it compiled and upon launching, the Fabric website showed me I had successfully integrated its library into my app.
Now that the app reports crashes, we can set up ProGuard more easily.