Skip to content

Commit f860ebe

Browse files
committed
Use the toml hash in the cache file name
- This allows a new emu to be created if dependencies are updated - Dependencies being updated can cause signature mismatches in installed test apks - also add back the KSP change that was removed..
1 parent dc01b26 commit f860ebe

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,18 @@ jobs:
7474
path: |
7575
~/.android/avd/*
7676
~/.android/adb*
77-
key: avd-cached-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}
77+
key: avd-cached-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}-${{ hashFiles('**/libs.versions.toml') }}
78+
restore-keys: |
79+
avd-cached-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}-
7880
- name: Create AVD and generate snapshot for caching
7981
if: steps.avd-cache.outputs.cache-hit != 'true'
8082
uses: reactivecircus/android-emulator-runner@v2
8183
with:
8284
api-level: ${{ matrix.api-level }}
8385
target: ${{ matrix.target }}
8486
arch: ${{ matrix.arch }}
85-
force-avd-creation: false
87+
# FORCE true here ensures if 'actions/cache' restored old avd, we wipe and start with a fresh image for the new dependency hash.
88+
force-avd-creation: true
8689
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-load
8790
disable-animations: false
8891
script: echo "Generated AVD snapshot for caching."
@@ -95,14 +98,6 @@ jobs:
9598
arch: ${{ matrix.arch }}
9699
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save
97100
script: |
98-
# Uninstall existing packages to avoid INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES
99-
# when a cached AVD snapshot has old APKs signed with different keys.
100-
adb uninstall com.squareup.leakcanary || true
101-
adb uninstall com.squareup.leakcanary.test || true
102-
adb uninstall com.squareup.leakcanary.core || true
103-
adb uninstall com.squareup.leakcanary.core.test || true
104-
adb uninstall com.squareup.leakcanary.instrumentation || true
105-
adb uninstall com.squareup.leakcanary.instrumentation.test || true
106101
touch emulator.log
107102
chmod 777 emulator.log
108103
adb logcat >> emulator.log &

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ buildscript {
1616
dependencies {
1717
classpath(libs.gradlePlugin.android)
1818
classpath(libs.gradlePlugin.kotlin)
19+
classpath(libs.gradlePlugin.ksp)
1920
classpath(libs.gradlePlugin.dokka)
2021
classpath(libs.gradlePlugin.mavenPublish)
2122
classpath(libs.gradlePlugin.detekt)

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# The benefit is that depending clients do not have to upgrade to Kotlin 1.4
1818
compose = "1.4.3"
1919
kotlin = "1.8.21"
20+
ksp = "1.8.21-1.0.11"
2021
coroutines = "1.7.3"
2122
androidXTest = "1.5.0"
2223
androidXJunit = "1.1.5"
@@ -29,6 +30,7 @@ androidCompileSdk = "35"
2930
[libraries]
3031
gradlePlugin-android = { module = "com.android.tools.build:gradle", version = "8.2.2" }
3132
gradlePlugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
33+
gradlePlugin-ksp = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
3234
gradlePlugin-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version = "1.8.10" }
3335
gradlePlugin-binaryCompatibility = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version = "0.13.1" }
3436
gradlePlugin-mavenPublish = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.25.2" }

leakcanary/leakcanary-app/build.gradle.kts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id("org.jetbrains.kotlin.android")
66
id("app.cash.sqldelight")
77
id("com.google.dagger.hilt.android")
8-
id("kotlin-kapt")
8+
id("com.google.devtools.ksp")
99
id("kotlin-parcelize")
1010
}
1111

@@ -96,9 +96,5 @@ dependencies {
9696
implementation(projects.leakcanary.leakcanaryAndroid)
9797
implementation(libs.hilt.android)
9898
implementation(libs.okio2)
99-
kapt(libs.hilt.compiler)
100-
}
101-
102-
kapt {
103-
correctErrorTypes = true
99+
ksp(libs.hilt.compiler)
104100
}

0 commit comments

Comments
 (0)