From 98f2f0e74f718bad524cca01170ca3b11528d49c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Fri, 1 May 2020 19:00:42 +0200 Subject: [PATCH] Migrate from fabric to firebase crashlytics (#789) --- .travis.yml | 9 +--- app/build.gradle | 14 ++--- app/src/main/AndroidManifest.xml | 27 ++++++++-- .../java/io/github/wulkanowy/WulkanowyApp.kt | 2 - .../java/io/github/wulkanowy/utils/AppInfo.kt | 3 -- .../wulkanowy/utils/CrashlyticsUtils.kt | 54 +++++++++++-------- build.gradle | 6 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- 8 files changed, 66 insertions(+), 51 deletions(-) diff --git a/.travis.yml b/.travis.yml index 514e37c0..88b711a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,20 +48,15 @@ before_script: script: - ./gradlew dependencies --stacktrace --daemon - fossa --no-ansi || true - #- ./gradlew lintPlayRelease -x fabricGenerateResourcesPlayRelease --stacktrace --daemon - - ./gradlew -Pcoverage testPlayDebugUnitTest -x fabricGenerateResourcesPlay --stacktrace --daemon + - ./gradlew -Pcoverage testPlayDebugUnitTest --stacktrace --daemon - ./gradlew -Pcoverage createFdroidDebugCoverageReport --stacktrace --daemon - ./gradlew -Pcoverage jacocoTestReport --stacktrace --daemon - - if [ -z ${SONAR_HOST+x} ]; then echo "sonar scan skipped"; else - git fetch --unshallow; - ./gradlew sonarqube -x test -x lint -x fabricGenerateResourcesPlayRelease -x fabricGenerateResourcesFdroidRelease -Dsonar.host.url=$SONAR_HOST -Dsonar.organization=$SONAR_ORG -Dsonar.login=$SONAR_KEY -Dsonar.branch.name=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH} --stacktrace --daemon; - fi - | if [ $TRAVIS_TAG ]; then gpg --yes --batch --passphrase=$SERVICES_ENCRYPT_KEY ./app/src/release/google-services.json.gpg; gpg --yes --batch --passphrase=$ENCRYPT_KEY ./app/key.p12.gpg; gpg --yes --batch --passphrase=$ENCRYPT_KEY ./app/upload-key.jks.gpg; - ./gradlew publishPlayRelease -PenableCrashlytics --stacktrace; + ./gradlew publishPlayRelease -PenableFirebase --stacktrace; fi after_success: diff --git a/app/build.gradle b/app/build.gradle index 7c311dfc..3d8fd082 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-android-extensions' -apply plugin: 'io.fabric' +apply plugin: 'com.google.firebase.crashlytics' apply plugin: 'com.github.triplet.play' apply plugin: 'com.mikepenz.aboutlibraries.plugin' apply from: 'jacoco.gradle' @@ -24,8 +24,7 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true manifestPlaceholders = [ - fabric_api_key : System.getenv("FABRIC_API_KEY") ?: "null", - crashlytics_enabled: project.hasProperty("enableCrashlytics") + firebase_enabled: project.hasProperty("enableFirebase") ] javaCompileOptions { annotationProcessorOptions { @@ -52,18 +51,16 @@ android { buildTypes { release { - buildConfigField "boolean", "CRASHLYTICS_ENABLED", "true" minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } debug { - buildConfigField "boolean", "CRASHLYTICS_ENABLED", project.hasProperty("enableCrashlytics") ? "true" : "false" applicationIdSuffix ".dev" versionNameSuffix "-dev" testCoverageEnabled = project.hasProperty('coverage') - ext.enableCrashlytics = project.hasProperty("enableCrashlytics") + ext.enableCrashlytics = project.hasProperty("enableFirebase") } } @@ -75,7 +72,6 @@ android { } fdroid { - buildConfigField "boolean", "CRASHLYTICS_ENABLED", "false" dimension "platform" } } @@ -190,8 +186,8 @@ dependencies { playImplementation 'com.google.firebase:firebase-analytics:17.4.0' playImplementation 'com.google.firebase:firebase-inappmessaging-display-ktx:19.0.6' playImplementation "com.google.firebase:firebase-inappmessaging-ktx:19.0.6" - playImplementation "com.google.firebase:firebase-messaging:20.1.0" - playImplementation "com.crashlytics.sdk.android:crashlytics:2.10.1" + playImplementation 'com.google.firebase:firebase-messaging:20.1.6' + playImplementation 'com.google.firebase:firebase-crashlytics:17.0.0' playImplementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava' releaseImplementation "com.github.ChuckerTeam.Chucker:library-no-op:$chucker" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 42c75475..4478f408 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -107,12 +107,33 @@ android:resource="@xml/provider_paths" /> + + + + + android:name="firebase_analytics_collection_enabled" + android:value="${firebase_enabled}" /> + + + + android:value="${firebase_enabled}" /> + + + +