summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2022-02-17 09:27:22 +0100
committerAlbin <albin@mullvad.net>2022-02-17 09:27:29 +0100
commit4a09f51122b7b9531df8e9aae424fa479457de6a (patch)
treeca31be7f13d4169b7d0567edee999c5a94d59330 /android
parent96cb2008d9a79a6923eee34537dd264a18c79512 (diff)
downloadmullvadvpn-4a09f51122b7b9531df8e9aae424fa479457de6a.tar.xz
mullvadvpn-4a09f51122b7b9531df8e9aae424fa479457de6a.zip
Add Android memory leak detection build type
Adds a new build type which can be used to identify memory leaks by using the Leak Canary dependency/tool.
Diffstat (limited to 'android')
-rw-r--r--android/app/build.gradle.kts11
-rw-r--r--android/buildSrc/src/main/kotlin/Dependencies.kt1
-rw-r--r--android/buildSrc/src/main/kotlin/Extensions.kt6
-rw-r--r--android/buildSrc/src/main/kotlin/Versions.kt1
4 files changed, 17 insertions, 2 deletions
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index c3dd40d520..6fda8a8fad 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -57,6 +57,10 @@ android {
isMinifyEnabled = false
signingConfig = null
}
+
+ create("leakCanary") {
+ initWith(buildTypes.getByName("debug"))
+ }
}
sourceSets {
@@ -153,14 +157,17 @@ dependencies {
implementation(Dependencies.Kotlin.stdlib)
implementation(Dependencies.KotlinX.coroutinesAndroid)
- /* Test dependencies */
+ // Leak canary
+ leakCanaryImplementation(Dependencies.leakCanary)
+
+ // Test dependencies
testImplementation(Dependencies.Koin.test)
testImplementation(Dependencies.Kotlin.test)
testImplementation(Dependencies.KotlinX.coroutinesTest)
testImplementation(Dependencies.MockK.core)
testImplementation(Dependencies.junit)
- /* UI test dependencies */
+ // UI test dependencies
debugImplementation(Dependencies.AndroidX.fragmentTestning)
androidTestImplementation(Dependencies.AndroidX.espressoContrib)
androidTestImplementation(Dependencies.AndroidX.espressoCore)
diff --git a/android/buildSrc/src/main/kotlin/Dependencies.kt b/android/buildSrc/src/main/kotlin/Dependencies.kt
index c11afd0882..4c96391c88 100644
--- a/android/buildSrc/src/main/kotlin/Dependencies.kt
+++ b/android/buildSrc/src/main/kotlin/Dependencies.kt
@@ -3,6 +3,7 @@ object Dependencies {
const val commonsValidator = "commons-validator:commons-validator:${Versions.commonsValidator}"
const val jodaTime = "joda-time:joda-time:${Versions.jodaTime}"
const val junit = "junit:junit:${Versions.junit}"
+ const val leakCanary = "com.squareup.leakcanary:leakcanary-android:${Versions.leakCanary}"
object AndroidX {
const val appcompat = "androidx.appcompat:appcompat:${Versions.AndroidX.appcompat}"
diff --git a/android/buildSrc/src/main/kotlin/Extensions.kt b/android/buildSrc/src/main/kotlin/Extensions.kt
index 3603330d3f..8659cb8ecb 100644
--- a/android/buildSrc/src/main/kotlin/Extensions.kt
+++ b/android/buildSrc/src/main/kotlin/Extensions.kt
@@ -1,3 +1,6 @@
+import org.gradle.api.artifacts.Dependency
+import org.gradle.api.artifacts.dsl.DependencyHandler
+
fun String.isNonStableVersion(): Boolean {
val nonStableQualifiers = listOf("alpha", "beta", "rc")
@@ -7,3 +10,6 @@ fun String.isNonStableVersion(): Boolean {
return isNonStable
}
+
+fun DependencyHandler.`leakCanaryImplementation`(dependencyNotation: Any): Dependency? =
+ add("leakCanaryImplementation", dependencyNotation)
diff --git a/android/buildSrc/src/main/kotlin/Versions.kt b/android/buildSrc/src/main/kotlin/Versions.kt
index c2fec7a42e..23e8571867 100644
--- a/android/buildSrc/src/main/kotlin/Versions.kt
+++ b/android/buildSrc/src/main/kotlin/Versions.kt
@@ -6,6 +6,7 @@ object Versions {
const val koin = "2.2.2"
const val kotlin = "1.4.31"
const val kotlinx = "1.5.1"
+ const val leakCanary = "2.8.1"
const val mockk = "1.12.0"
object Android {