Add LeakCanary for debug versions of the app

This commit is contained in:
Jonathan Caryl 2017-08-12 21:46:57 +01:00
parent 3eef430226
commit 1beab19679
10 changed files with 42 additions and 2 deletions

View File

@ -33,9 +33,15 @@ android {
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
debug.java.srcDirs += 'src/debug/kotlin'
release.java.srcDirs += 'src/release/kotlin'
}
}
ext {
leakCanaryVersion = '1.5.2'
}
dependencies {
compile 'com.simplemobiletools:commons:2.25.3'
compile 'joda-time:joda-time:2.9.1'
@ -57,6 +63,8 @@ dependencies {
}
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
debugCompile "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
}
buildscript {

View File

@ -0,0 +1,14 @@
package com.simplemobiletools.calendar
import com.squareup.leakcanary.LeakCanary
open class BuildVariantApplication : BaseApp() {
override fun onCreate() {
super.onCreate()
LeakCanary.install(this);
}
override fun shouldInit(): Boolean {
return !LeakCanary.isInAnalyzerProcess(this)
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="leak_canary_display_activity_label">Calendar Leaks</string>
</resources>

View File

@ -1,11 +1,13 @@
package com.simplemobiletools.calendar
import android.support.multidex.MultiDexApplication
import com.facebook.stetho.Stetho
class App : MultiDexApplication() {
class App : BuildVariantApplication() {
override fun onCreate() {
super.onCreate()
if (!shouldInit()) {
return
}
Stetho.initializeWithDefaults(this)
}
}

View File

@ -0,0 +1,9 @@
package com.simplemobiletools.calendar
import android.support.multidex.MultiDexApplication
abstract class BaseApp : MultiDexApplication() {
open fun shouldInit(): Boolean {
return true
}
}

View File

@ -0,0 +1,3 @@
package com.simplemobiletools.calendar
open class BuildVariantApplication : BaseApp()