Skip to content

Use BuildService to fetch adb path instead of caching in a companion object#274

Draft
DanielJette wants to merge 13 commits intomainfrom
adb-service
Draft

Use BuildService to fetch adb path instead of caching in a companion object#274
DanielJette wants to merge 13 commits intomainfrom
adb-service

Conversation

@DanielJette
Copy link
Contributor

What does this change accomplish?

How have you achieved it?

Scope of Impact and Testing instructions

Notice

Warning

This change must keep main in a shippable state; it may be shipped without further notice.

dfabulich and others added 12 commits February 15, 2026 16:55
https://developer.android.com/build/releases/agp-9-0-0-release-notes

1. In AGP 9.0, the old variants API is removed. The new `androidComponents.onVariants` API is callback-based and `Property` values cannot be accessed during configuration.
    We now compute applicationTargetPackageId by using `defaultConfig.applicationId`, accounting for `applicationIdSuffix` from build types, and we then use `applicationTargetPackageId` to infer the default test variant ID.

    (We prefer the debug build type suffix since that's typically what's used for testing.)

    Note: This doesn't account for flavor-specific `applicationIds` or complex flavor dimension combinations, but users can override by explicitly setting `applicationPackageId` in their `testify` extension.

2. `android.defaultConfig { ... }` takes a lambda with receiver, not a lambda with a parameter, so we can remove `it.resValue` and just call `resValue`.

3. In AGP 9.0, `adb` is accessed via `androidComponents.sdkComponents.adb`, and `sdkComponents` isn't available during configuration time. We now defer resolution until execution time.
We now use `AndroidSourceDirectorySet.directories` instead of the deprecated `AndroidSourceDirectorySet.srcDirs`.
The AGP 9 change made `Project.android` use only `ApplicationExtension`, but the `Samples` also include library modules (e.g. :FlixLibrary, :ComposeExtensions). Those use `LibraryExtension`, so `findByType(ApplicationExtension::class.java)` was null and the plugin threw “Gradle project must contain an android closure” during configuration (e.g. when running ./gradlew dependencies).

(Library modules are required to set `applicationPackageId` in their `testify` block, so it's OK that `applicationTargetPackageId` returns null in that case.)
…and path while preserving gradle configuration caching
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

Comments