Enable crashlytics reports on release builds only, avoiding crashes in the debug version when trying to initialize crashlytics.

This commit is contained in:
Severiano Jaramillo 2019-01-31 12:18:21 -06:00
parent d0218727e9
commit 6e5c6b50b8
3 changed files with 8 additions and 19 deletions

View file

@ -30,7 +30,7 @@ android {
shrinkResources false shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// enable crashlytics // enable crashlytics
buildConfigField "boolean", "USE_CRASHLYTICS", "true" ext.enableCrashlytics = true
} }
debug { debug {
// TODO enabling minify breaks the debugger breakpoints, find a way to fix it and enable minify again // TODO enabling minify breaks the debugger breakpoints, find a way to fix it and enable minify again
@ -38,7 +38,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue("string", "PORT_NUMBER", "8082") resValue("string", "PORT_NUMBER", "8082")
// disable crashlytics // disable crashlytics
buildConfigField "boolean", "USE_CRASHLYTICS", "false" ext.enableCrashlytics = false
} }
} }
android.packagingOptions { android.packagingOptions {

View file

@ -3,11 +3,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="cy.agorise.bitsybitshareswallet"> package="cy.agorise.bitsybitshareswallet">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.CAMERA"/>
@ -24,17 +19,10 @@
android:theme="@style/Theme.Bitsy" android:theme="@style/Theme.Bitsy"
tools:ignore="GoogleAppIndexingWarning"> tools:ignore="GoogleAppIndexingWarning">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data <meta-data
android:name="com.google.android.geo.API_KEY" android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key"/> android:value="@string/google_maps_key"/>
<!-- Avoid Crashlytics crash collection for all users/builds -->
<meta-data <meta-data
android:name="firebase_crashlytics_collection_enabled" android:name="firebase_crashlytics_collection_enabled"
android:value="false" /> android:value="false" />

View file

@ -14,6 +14,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
import com.crashlytics.android.core.CrashlyticsCore
import cy.agorise.bitsybitshareswallet.BuildConfig import cy.agorise.bitsybitshareswallet.BuildConfig
import cy.agorise.bitsybitshareswallet.database.entities.Balance import cy.agorise.bitsybitshareswallet.database.entities.Balance
import cy.agorise.bitsybitshareswallet.processors.TransfersLoader import cy.agorise.bitsybitshareswallet.processors.TransfersLoader
@ -97,10 +98,10 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
if (BuildConfig.USE_CRASHLYTICS) { val crashlytics = Crashlytics.Builder()
// Enabling crashlytics reports on release builds only .core(CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
Fabric.with(this, Crashlytics()) .build()
} Fabric.with(this, crashlytics)
getUserAccount() getUserAccount()