Skip to content

Update Gradle, AGP, Hilt#2799

Merged
pyricau merged 8 commits intosquare:mainfrom
blundell:fix-instru-tests
Feb 26, 2026
Merged

Update Gradle, AGP, Hilt#2799
pyricau merged 8 commits intosquare:mainfrom
blundell:fix-instru-tests

Conversation

@blundell
Copy link
Contributor

@blundell blundell commented Feb 26, 2026

Updates Android instrumentation test dependencies and configuration to work with compileSdk 35 and API level 36:

  • Update AGP to 8.2.2 and Gradle to 8.2
  • Update Hilt to consistently be 2.53
  • Update AndroidX Test dependencies to modern versions compatible with API 36
  • Fix test namespace configuration to match actual package structure
  • Move TuPeuxPasTest to correct package structure for proper test discovery
  • Fixes build warnings about packagingOptions
  • Add missing Java sourceCompatibility declarations

@blundell blundell marked this pull request as draft February 26, 2026 09:43
@blundell
Copy link
Contributor Author

the CI currently has the same problem I have locally

2026-02-26T09:46:39.4413492Z Caused by: org.gradle.api.GradleException: There were failing tests. See the report at: file:///home/runner/work/leakcanary/leakcanary/leakcanary/leakcanary-android-core/build/reports/androidTests/connected/debug/index.html
2026-02-26T09:46:42.6968778Z Artifact download URL: https://github.com/square/leakcanary/actions/runs/22436454289/artifacts/5669567490

image

the report is not capturing the test runs

@blundell
Copy link
Contributor Author

blundell commented Feb 26, 2026

  • Main / instrumentation-tests (x86_64, google_apis, stable, 23) (pull_request)

"progress" maybe (with AGP 8.2.2)

image image

blundell and others added 3 commits February 26, 2026 13:12
Updates Android instrumentation test dependencies and configuration to work with compileSdk 35 and API level 36:

- Update Gradle from 8.2 to 8.10.2
- Move from KAPT to KSP
- Update AGP to 8.2.2 and Gradle to 8.2
- Update Hilt to consistently be 2.53
- Update AndroidX Test dependencies to modern versions compatible with API 36
- Fix test namespace configuration to match actual package structure
- Move TuPeuxPasTest to correct package structure for proper test discovery
- Fixes build warnings about packagingOptions
- Add missing Java sourceCompatibility declarations
- Appease lint by suppressing the failures, we could remove the checks but they where written for a reason so keeping them

This ensures UI tests are properly discovered and executed by Gradle with correct reporting, while maintaining compatibility with newer Android APIs.

Co-Authored-By: Claude <noreply@anthropic.com>
What These Changes Mean:

  Removed Methods: getDefaultImpl() and setDefaultImpl()
  These were part of an older AIDL pattern for handling default implementations when the service isn't available. This was a fallback mechanism that's been deprecated in favor of better error handling.

  Added: DESCRIPTOR Field
  This is the standard AIDL interface descriptor string - it's always been there internally, but now it's explicitly exposed in the public API.

  Added: LeakUiApp$_Parcel Class
  This is a newer AIDL tooling artifact - modern AIDL compilers generate additional helper classes for parcelization.

  Impact Analysis: ✅ Likely SAFE - No Breaking Changes for Clients

  Why this is probably fine:
  1. Internal APIs: These are in org.leakcanary.internal.* package - the internal namespace signals these aren't meant for public consumption
  2. AIDL Evolution: The Android AIDL compiler has been evolving to generate more modern, efficient code. The removed methods were legacy patterns.
  3. Backwards Compatible:
  - The core sendHeapAnalysis() method remains unchanged
    - The DESCRIPTOR field addition doesn't break existing clients
    - The new _Parcel class is just tooling infrastructure
  4. LeakCanary Context: This appears to be inter-process communication between LeakCanary components, not a public API for app developers
  ⚠️ Potential Concerns:
  1. If any external code was using the removed methods (unlikely since they're internal APIs)
  2. Binary compatibility for any code that was directly instantiating or reflection-accessing these classes

 What Could Have Caused This:
  1. Java 17 + newer Android Gradle Plugin - may use a newer AIDL compiler
  2. Updated compileOptions - could affect how AIDL generates code
  3. Build environment changes - newer toolchain versions
Recommendation:
  This is likely safe because:
  - It's internal LeakCanary APIs
  - The core functionality (sendHeapAnalysis) is preserved
  - This follows AIDL tooling evolution patterns

 However, you should consider:
  - Testing: Ensure LeakCanary still works properly between processes
  - Release notes: Document that internal AIDL APIs changed (if you publish these changes)
  - Monitoring: Watch for any reports of inter-process communication issues

 The changes appear to be tooling evolution rather than functional changes, but it's worth testing the actual LeakCanary functionality to be sure.
@blundell blundell changed the title Fix UI test infrastructure (by updating dependencies) Update Gradle, AGP, Hilt and replace KAPT with KSP Feb 26, 2026
@blundell
Copy link
Contributor Author

  • Main / instrumentation-tests (x86_64, google_apis, stable, 23) (pull_request)

"progress" maybe (with AGP 8.2.2)

Fixed by : #2801

- This allows a new emu to be created if dependencies are updated
- Dependencies being updated can cause signature mismatches in installed test apks
@blundell blundell changed the title Update Gradle, AGP, Hilt and replace KAPT with KSP Update Gradle, AGP, Hilt Feb 26, 2026
- allow the instrumentation tests running an API 16 to pass
@blundell blundell marked this pull request as ready for review February 26, 2026 16:28
arch: ${{ matrix.arch }}
force-avd-creation: false
# FORCE true here ensures if 'actions/cache' restored old avd, we wipe and start with a fresh image for the new dependency hash.
force-avd-creation: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we create a new AVD on every run? Doesn't that slow down CI?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No — only when libs.versions.toml changes. The step has if: steps.avd-cache.outputs.cache-hit != 'true', so it's skipped entirely on an exact cache hit. The key includes hashFiles('**/libs.versions.toml'), so on runs where deps haven't changed the key matches → cache-hit = 'true' → step is skipped entirely.

force-avd-creation: true only matters when the step does run (cache miss or partial match via restore-keys): it ensures any restored but stale AVD snapshot is wiped and a fresh one is created, rather than reusing a snapshot from a different dep version. The Instrumentation Tests step keeps force-avd-creation: false so it always reuses whatever snapshot was just created (or retrieved from an exact cache hit).

key: avd-cached-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}
key: avd-cached-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}-${{ hashFiles('**/libs.versions.toml') }}
restore-keys: |
avd-cached-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this about?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache fallback. The exact key includes hashFiles('**/libs.versions.toml'), so when deps change there's no exact match. Without restore-keys, that's a total cache miss — the emulator runner has to set up everything from scratch. With restore-keys: avd-cached-{api-level}-{os}-{target}-, GitHub will restore the most recent cached AVD for that API level/target combination (from a previous dep version) as a partial restore. Then force-avd-creation: true wipes that old snapshot and creates a fresh one, which gets saved under the new key.


@TargetApi(M) fun hasStoragePermission(): Boolean {
// Defensive check: @TargetApi doesn't prevent this method from being called on older APIs
@Suppress("ObsoleteSdkInt") // Intentional safety check despite @TargetApi annotation
Copy link
Member

@pyricau pyricau Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • never put a comment at the end of a line of code

fun createPendingIntent(context: Context, permission: String): PendingIntent {
val intent = createIntent(context, permission)
// Defensive check: @TargetApi on class doesn't prevent this method from being called on older APIs
@Suppress("ObsoleteSdkInt") // Intentional safety check despite @TargetApi annotation
Copy link
Member

@pyricau pyricau Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • never put a comment at the end of a line of code

pyricau and others added 2 commits February 26, 2026 21:28
* origin/main:
  Pin gradle/actions/wrapper-validation to commit SHA to satisfy code scanning
  Drop API 28 and 29 from instrumentation test matrix
  Fix LeakActivityTest on API 33+ by disabling notifications during test
  Fix INSTALL_FAILED_DEPRECATED_SDK_VERSION on API 28+ for leakcanary-android tests
  Upgrade wrapper-validation-action to gradle/actions/wrapper-validation@v4
  Add recent Android API levels to instrumentation test matrix
  Fix pkill self-match: use qemu-syste[m] pattern
  Update changelog entry wording for ToastEventListener fix
  Fix emulator process hanging 20+ min after CI tests finish
  Add changelog entry for ToastEventListener race condition fix
  Fix ToastEventListener race condition retaining finished Toast
Move the explanation to the preceding comment line instead of appending
it to the annotation itself, per project style conventions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pyricau pyricau merged commit a6d2b6b into square:main Feb 26, 2026
13 checks passed
@blundell blundell deleted the fix-instru-tests branch February 26, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants