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
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// enable crashlytics
buildConfigField "boolean", "USE_CRASHLYTICS", "true"
ext.enableCrashlytics = true
}
debug {
// 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'
resValue("string", "PORT_NUMBER", "8082")
// disable crashlytics
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
ext.enableCrashlytics = false
}
}
android.packagingOptions {

View file

@ -3,11 +3,6 @@
xmlns:tools="http://schemas.android.com/tools"
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.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
@ -24,17 +19,10 @@
android:theme="@style/Theme.Bitsy"
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
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key"/>
<!-- Avoid Crashlytics crash collection for all users/builds -->
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />

View file

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