Skip to content

Commit d830d05

Browse files
committed
Clear previous installs that may be cached
- Fixes the error: Exception thrown during onBeforeAll invocation of plugin com.android.tools.utp.plugins.host.apkinstaller.AndroidTestApkInstallerPlugin. Failed to install APK(s): /home/runner/work/leakcanary/leakcanary/leakcanary/leakcanary-android/build/outputs/apk/androidTest/debug/leakcanary-android-debug-androidTest.apk INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES com.android.ddmlib.InstallException: INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES at com.android.ddmlib.internal.DeviceImpl.installRemotePackage(DeviceImpl.java:1409)
1 parent 1c4510c commit d830d05

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,20 @@ jobs:
9595
arch: ${{ matrix.arch }}
9696
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save
9797
script: |
98+
# Attempt to clear existing installs that might conflict with cached snapshots
99+
# Use || true to prevent the script from failing if the app isn't installed
100+
# We could avoid using this command if we use a debug keystore to guarantee apk compatibility
101+
for pkg in $(adb shell pm list packages leakcanary | cut -d ':' -f 2 | tr -d '\r'); do
102+
echo "Uninstalling existing package: $pkg"
103+
adb uninstall $pkg || true
104+
done
98105
touch emulator.log # create log file
99106
chmod 777 emulator.log # allow writing to log file
100107
adb logcat >> emulator.log & # pipe all logcat messages into log file as a background process
101-
./gradlew leakcanary:leakcanary-android-core:connectedCheck leakcanary:leakcanary-android:connectedCheck leakcanary:leakcanary-android-instrumentation:connectedCheck --no-build-cache --no-daemon --stacktrace
108+
./gradlew leakcanary:leakcanary-android-core:connectedCheck \
109+
leakcanary:leakcanary-android:connectedCheck \
110+
leakcanary:leakcanary-android-instrumentation:connectedCheck \
111+
--no-build-cache --no-daemon --stacktrace
102112
- name: Upload results
103113
if: ${{ always() }}
104114
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)