adding Leak Canary

This commit is contained in:
tibbi 2017-11-20 17:00:24 +01:00
parent 50df58f7f0
commit 74a258974c
3 changed files with 37 additions and 0 deletions

View File

@ -20,10 +20,14 @@ android {
}
buildTypes {
debug {
buildConfigField "boolean", "USE_LEAK_CANARY", "true"
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
buildConfigField "boolean", "USE_LEAK_CANARY", "false"
}
}
@ -37,8 +41,15 @@ android {
}
}
ext {
leakCanaryVersion = '1.5.4'
}
dependencies {
implementation 'com.simplemobiletools:commons:2.41.5'
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
}
Properties props = new Properties()

View File

@ -10,6 +10,7 @@
tools:node="remove"/>
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_launcher_name"

View File

@ -0,0 +1,25 @@
package com.simplemobiletools.draw
import android.app.Application
import com.simplemobiletools.draw.BuildConfig.USE_LEAK_CANARY
import com.simplemobiletools.draw.extensions.config
import com.squareup.leakcanary.LeakCanary
import java.util.*
class App : Application() {
override fun onCreate() {
super.onCreate()
if (USE_LEAK_CANARY) {
if (LeakCanary.isInAnalyzerProcess(this)) {
return
}
LeakCanary.install(this)
}
if (config.useEnglish) {
val conf = resources.configuration
conf.locale = Locale.ENGLISH
resources.updateConfiguration(conf, resources.displayMetrics)
}
}
}