diff --git a/.gitignore b/.gitignore index cc652f6..02c62f6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ *.log .idea/ *~ +acra.properties \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 45ad451..d52d998 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,15 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' +Properties acra = new Properties() +acra.load(new FileInputStream("app/acra.properties")) + android { compileSdkVersion 27 + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } defaultConfig { applicationId "com.wbrawner.myallowance" minSdkVersion 23 @@ -19,6 +26,9 @@ android { useSupportLibrary = true } testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + buildConfigField "String", "ACRA_URL", "\"${acra.getProperty("url")}\"" + buildConfigField "String", "ACRA_USER", "\"${acra.getProperty("user")}\"" + buildConfigField "String", "ACRA_PASS", "\"${acra.getProperty("pass")}\"" } buildTypes { release { @@ -43,6 +53,10 @@ dependencies { kapt "android.arch.persistence.room:compiler:$room_version" testImplementation "android.arch.persistence.room:testing:$room_version" testImplementation 'junit:junit:4.12' + + // ACRA Crash reporting + def acraVersion = '5.1.3' + implementation "ch.acra:acra-http:$acraVersion" androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } diff --git a/app/src/main/java/com/wbrawner/myallowance/AllowanceApplication.kt b/app/src/main/java/com/wbrawner/myallowance/AllowanceApplication.kt index 0cc4c5a..dce7f4f 100644 --- a/app/src/main/java/com/wbrawner/myallowance/AllowanceApplication.kt +++ b/app/src/main/java/com/wbrawner/myallowance/AllowanceApplication.kt @@ -1,12 +1,21 @@ package com.wbrawner.myallowance import android.app.Application -import android.arch.lifecycle.ViewModelProvider import android.arch.persistence.room.Room -import android.arch.persistence.room.Transaction +import android.content.Context import com.wbrawner.myallowance.data.TransactionDao import com.wbrawner.myallowance.data.TransactionsDatabase +import org.acra.ACRA +import org.acra.annotation.AcraCore +import org.acra.annotation.AcraHttpSender +import org.acra.data.StringFormat +import org.acra.sender.HttpSender +@AcraCore(reportFormat = StringFormat.JSON) +@AcraHttpSender(uri = BuildConfig.ACRA_URL, + basicAuthLogin = BuildConfig.ACRA_USER, + basicAuthPassword = BuildConfig.ACRA_PASS, + httpMethod = HttpSender.Method.POST) class AllowanceApplication: Application() { lateinit var database: TransactionsDatabase private set @@ -20,6 +29,11 @@ class AllowanceApplication: Application() { database = Room.databaseBuilder(applicationContext, TransactionsDatabase::class.java, "transactions") .build() dao = database.dao() + } + + override fun attachBaseContext(base: Context?) { + super.attachBaseContext(base) + ACRA.init(this) } } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3880fd4..6a0f417 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' + classpath 'com.android.tools.build:gradle:3.1.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong