Skip to content

Make Protobuf Gradle Plugin AGP 9 compatible#797

Open
omarismail94 wants to merge 2 commits intogoogle:masterfrom
omarismail94:master
Open

Make Protobuf Gradle Plugin AGP 9 compatible#797
omarismail94 wants to merge 2 commits intogoogle:masterfrom
omarismail94:master

Conversation

@omarismail94
Copy link
Contributor

@omarismail94 omarismail94 commented Jan 30, 2026

Establish AGP 7.4 as the minimum supported version and adhere to the new Variant APIs. This ensures forward compatibility with AGP 9.0 while optimizing for the majority of the active ecosystem.

To achieve forward compatibility with AGP 9, the plugin must eliminate all reliance on the "Old Variant API" (BaseVariant, AppExtension, registerJavaGeneratingTask).

  • Migrate ProtobufPlugin to use the AndroidComponentsExtension (Variant API) instead of the deprecated BaseVariant API.
  • Replace registerJavaGeneratingTask with variant.sources.java.addGeneratedSourceDirectory for source registration.
  • Remove ProjectExt and legacy variant iteration logic.
  • Remove deprecated AndroidSourceSet extension in Kotlin.

FIXES: Issue #787 , #793

TESTED:

  • Compilation passed: Ran ./gradlew assemble
  • Added tests to cover AGP 9 behaviour
  • All tests passed: Ran ./gradlew test
  • Published local snapshot, uploaded to AndroidX, and set android.newDsl to true and the build passed. See here

@michnovka
Copy link

Hello, wondering if this is merge ready, or we need something to be done? This is the last blocker for us to move to AGP9 fully. Thanks!

@omarismail94
Copy link
Contributor Author

@michnovka Im just waiting for someone from the owning team to review the change. The regular reviewer is out of office this week, but will try to find someone else. If I don't, then expect it to be reviewed next week

Copy link
Collaborator

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

I've looked over the first commit, and yes some of the versions will need to change (like discussed over email), but it looks pretty good and I think could go in relatively quickly. I still need to look over the test project changes; it seems there's more than codenarc fixes (I understand some parts of what is going on; just didn't have time to look through all of them)

I think we'll want to split out that first commit into a separate PR, and I'll be the main reviewer for it, and that'll make the AGP changes then easier to review.

@omarismail94
Copy link
Contributor Author

@ejona86 I've created a separate PR for upgrading the gradle version, and rebased this PR on it.

Can you review both please? Here is the initial one: #800

@omarismail94
Copy link
Contributor Author

omarismail94 commented Feb 19, 2026

@ejona86 this is ready for review now. I rebased the commit from PR #800 rn on this PR

- Migrate `ProtobufPlugin` to use the `AndroidComponentsExtension` (Variant API) instead of the deprecated `BaseVariant` API.
- Replace `registerJavaGeneratingTask` with `variant.sources.java.addGeneratedSourceDirectory` for source registration.
- Remove `ProjectExt` and legacy variant iteration logic.
- Remove deprecated `AndroidSourceSet` extension in Kotlin.
@omarismail94 omarismail94 force-pushed the master branch 3 times, most recently from c34616e to eebeeda Compare February 23, 2026 14:51
@tellypresence
Copy link

tellypresence commented Mar 3, 2026

AGP 9.0.1 9.1.0 has been released, any progress on this?

@michnovka
Copy link

@omarismail94 Hi, could you please merge this? Tests pass and this is the stopper for us to upgrade AGP

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.

5 participants