upgrade fabric to firebase

This commit is contained in:
Milos Kozak 2020-05-31 10:12:36 +02:00
parent b9806d0ea9
commit 31b3177561
6 changed files with 13 additions and 68 deletions

View file

@ -1,13 +1,10 @@
buildscript { buildscript {
repositories { repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4' classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4'
classpath 'de.undercouch:gradle-download-task:3.4.3'
} }
} }
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
@ -15,10 +12,8 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
apply plugin: 'jacoco-android' apply plugin: 'jacoco-android'
apply plugin: 'de.undercouch.download' apply plugin: 'com.google.firebase.crashlytics'
jacoco { jacoco {
toolVersion = "0.8.3" toolVersion = "0.8.3"
@ -33,7 +28,6 @@ ext {
repositories { repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter { url "https://jcenter.bintray.com/" } jcenter { url "https://jcenter.bintray.com/" }
mavenCentral() mavenCentral()
} }
@ -249,12 +243,9 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-wearable:17.0.0' implementation 'com.google.android.gms:play-services-wearable:17.0.0'
implementation "com.google.android.gms:play-services-location:17.0.0" implementation "com.google.android.gms:play-services-location:17.0.0"
implementation 'com.google.firebase:firebase-core:17.4.0' implementation 'com.google.firebase:firebase-core:17.4.2'
implementation 'com.google.firebase:firebase-auth:19.3.1' implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-database:19.3.0' implementation 'com.google.firebase:firebase-database:19.3.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
transitive = true;
}
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0' implementation 'androidx.legacy:legacy-support-v13:1.0.0'

View file

@ -69,7 +69,7 @@ public class MainApp extends DaggerApplication {
sResources = getResources(); sResources = getResources();
LocaleHelper.INSTANCE.update(this); LocaleHelper.INSTANCE.update(this);
sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class); sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class);
/*
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> { Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> {
if (ex instanceof InternalError) { if (ex instanceof InternalError) {
// usually the app trying to spawn a thread while being killed // usually the app trying to spawn a thread while being killed
@ -77,7 +77,7 @@ public class MainApp extends DaggerApplication {
} }
aapsLogger.error("Uncaught exception crashing app", ex); aapsLogger.error("Uncaught exception crashing app", ex);
}); });
*/
registerActivityLifecycleCallbacks(activityMonitor); registerActivityLifecycleCallbacks(activityMonitor);
JodaTimeAndroid.init(this); JodaTimeAndroid.init(this);

View file

@ -17,12 +17,11 @@ buildscript {
repositories { repositories {
google() google()
jcenter() jcenter()
maven { url 'https://maven.fabric.io/public' }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.6.3' classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

View file

@ -58,10 +58,9 @@ dependencies {
//Logger //Logger
implementation 'org.slf4j:slf4j-api:1.7.30' implementation 'org.slf4j:slf4j-api:1.7.30'
//Fabric //Fabric
implementation 'com.google.firebase:firebase-core:17.4.0' implementation 'com.google.firebase:firebase-analytics-ktx:17.4.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') { implementation 'com.google.firebase:firebase-crashlytics:17.0.0'
transitive = true;
}
//RxBus //RxBus
implementation "io.reactivex.rxjava2:rxandroid:2.1.1" implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation 'org.apache.commons:commons-lang3:3.10' implementation 'org.apache.commons:commons-lang3:3.10'

View file

@ -82,7 +82,7 @@ public class Profile {
if (units != null) if (units != null)
this.units = units; this.units = units;
else { else {
fabricPrivacy.log("Profile failover failed too"); fabricPrivacy.logCustom("Profile failover failed too");
this.units = Constants.MGDL; this.units = Constants.MGDL;
} }
} }

View file

@ -2,13 +2,12 @@ package info.nightscout.androidaps.utils
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import com.crashlytics.android.Crashlytics
import com.google.firebase.analytics.FirebaseAnalytics import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.fabric.sdk.android.Fabric
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -27,21 +26,9 @@ class FabricPrivacy @Inject constructor(
var firebaseAnalytics: FirebaseAnalytics var firebaseAnalytics: FirebaseAnalytics
init { init {
instance = this
firebaseAnalytics = FirebaseAnalytics.getInstance(context) firebaseAnalytics = FirebaseAnalytics.getInstance(context)
firebaseAnalytics.setAnalyticsCollectionEnabled(!java.lang.Boolean.getBoolean("disableFirebase") && fabricEnabled()) firebaseAnalytics.setAnalyticsCollectionEnabled(!java.lang.Boolean.getBoolean("disableFirebase") && fabricEnabled())
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!java.lang.Boolean.getBoolean("disableFirebase") && fabricEnabled())
if (fabricEnabled()) {
Fabric.with(context, Crashlytics())
}
}
companion object {
private lateinit var instance: FabricPrivacy
@JvmStatic
@Deprecated("Use Dagger")
fun getInstance(): FabricPrivacy = instance
} }
// Analytics logCustom // Analytics logCustom
@ -76,39 +63,8 @@ class FabricPrivacy @Inject constructor(
// Crashlytics logException // Crashlytics logException
fun logException(throwable: Throwable) { fun logException(throwable: Throwable) {
try { FirebaseCrashlytics.getInstance().recordException(throwable)
val crashlytics = Crashlytics.getInstance() aapsLogger.debug(LTag.CORE, "Exception: ", throwable)
crashlytics.core.logException(throwable)
aapsLogger.debug(LTag.CORE, "Exception: ", throwable)
} catch (e: NullPointerException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $throwable")
} catch (e: IllegalStateException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $throwable")
}
}
// Crashlytics log
fun log(msg: String) {
try {
val crashlytics = Crashlytics.getInstance()
crashlytics.core.log(msg)
} catch (e: NullPointerException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $msg")
} catch (e: IllegalStateException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $msg")
}
}
// Crashlytics log
fun log(priority: Int, tag: String?, msg: String) {
try {
val crashlytics = Crashlytics.getInstance()
crashlytics.core.log(priority, tag, msg)
} catch (e: NullPointerException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $msg")
} catch (e: IllegalStateException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $msg")
}
} }
fun fabricEnabled(): Boolean { fun fabricEnabled(): Boolean {