Skip to content

Commit

Permalink
Migrate fabric → new firebase crashlytics SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
tadaskay committed Oct 22, 2020
1 parent dc62f28 commit 166df16
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 52 deletions.
29 changes: 7 additions & 22 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

import com.android.build.OutputFile

Expand Down Expand Up @@ -45,11 +46,6 @@ def getVersionName = { ->
*/
def enableSeparateBuildPerCPUArchitecture = false

/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion

Expand Down Expand Up @@ -110,12 +106,10 @@ android {
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
minifyEnabled true
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
debug {
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
signingConfig signingConfigs.debug
}
}
Expand Down Expand Up @@ -161,10 +155,10 @@ dependencies {
implementation 'com.android.support:support-compat:28.0.0'
implementation 'com.google.android.material:material:1.3.0-alpha01'

implementation 'com.google.firebase:firebase-core:17.2.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.6@aar') {
transitive = true
}
implementation platform('com.google.firebase:firebase-bom:25.12.0')
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'

implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.beust:klaxon:5.0.1'
implementation 'com.journeyapps:zxing-android-embedded:4.1.0'
Expand Down Expand Up @@ -193,15 +187,6 @@ task copyDownloadableDepsToLibs(type: Copy) {
into 'libs'
}

gradle.projectsEvaluated {
preBuild.dependsOn(applyGoogleServicesIfNeeded)
}

task applyGoogleServicesIfNeeded {
if (project.hasProperty('applyGoogleServices')) {
apply plugin: 'com.google.gms.google-services'
}
}
repositories {
mavenCentral()
}
5 changes: 1 addition & 4 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
</intent-filter>
</receiver>

<meta-data
android:name="io.fabric.ApiKey"
android:value="c614c88920a993fbd6030ed842b48214b0ebc689" />
<service
android:name="network.mysterium.service.core.MysteriumAndroidCoreService"
android:permission="android.permission.BIND_VPN_SERVICE">
Expand Down Expand Up @@ -101,4 +98,4 @@
android:value="false" />
</application>

</manifest>
</manifest>
21 changes: 3 additions & 18 deletions android/app/src/main/java/network/mysterium/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,22 @@ package network.mysterium

import android.util.Log
import androidx.multidex.MultiDexApplication
import com.crashlytics.android.Crashlytics
import com.crashlytics.android.core.CrashlyticsCore
import io.fabric.sdk.android.Fabric
import io.intercom.android.sdk.Intercom
import network.mysterium.logging.BugReporter
import network.mysterium.ui.Countries
import network.mysterium.vpn.BuildConfig

class MainApplication : MultiDexApplication() {

val appContainer = AppContainer()

override fun onCreate() {
setupLogging()
BugReporter.init()
super.onCreate()
Countries.loadBitmaps()
setupIntercom()
Log.i(TAG, "Application started")
}

private fun setupLogging() {
// https://docs.fabric.io/android/crashlytics/build-tools.html?highlight=crashlyticscore
// Set up Crashlytics, disabled for debug builds
val crashlyticsKit = Crashlytics.Builder()
.core(CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
.build()

// Initialize Fabric with the debug-disabled crashlytics.
Fabric.with(this, crashlyticsKit)

Crashlytics.setInt("android_sdk_int", android.os.Build.VERSION.SDK_INT)
}

private fun setupIntercom() {
Intercom.initialize(this, "android_sdk-e480f3fce4f2572742b13c282c453171c1715516", "h7hlm9on")
}
Expand Down
13 changes: 10 additions & 3 deletions android/app/src/main/java/network/mysterium/logging/BugReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@

package network.mysterium.logging

import com.crashlytics.android.Crashlytics
import com.google.firebase.crashlytics.FirebaseCrashlytics

class BugReporter {
fun setUserIdentifier(userIdentifier: String) {
Crashlytics.setUserIdentifier(userIdentifier)

companion object {
fun init() {
FirebaseCrashlytics.getInstance().setCustomKey("android_sdk_int", android.os.Build.VERSION.SDK_INT)
}
}

fun setUserIdentifier(userId: String) {
FirebaseCrashlytics.getInstance().setUserId(userId)
}
}
6 changes: 2 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'io.fabric.tools:gradle:1.31.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.gms:google-services:4.3.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -32,7 +31,6 @@ allprojects {
maven {
url 'https://dl.bintray.com/mysteriumnetwork/maven'
}
maven { url 'https://maven.fabric.io/public' }
maven {
url "https://oss.sonatype.org/service/local/repositories/releases/content/"
}
Expand Down
2 changes: 1 addition & 1 deletion fastlane/android_version_code
Original file line number Diff line number Diff line change
@@ -1 +1 @@
107083
107084

0 comments on commit 166df16

Please sign in to comment.