Skip to content

chore: migrate Android example to AGP 9#392

Merged
marandaneto merged 12 commits into
mainfrom
chore/agp9-example-migration
May 22, 2026
Merged

chore: migrate Android example to AGP 9#392
marandaneto merged 12 commits into
mainfrom
chore/agp9-example-migration

Conversation

@marandaneto
Copy link
Copy Markdown
Member

@marandaneto marandaneto commented May 22, 2026

💡 Motivation and Context

Migrate the Android example app to AGP 9.2.1 and Gradle 9.4.1, while aligning the example Android project structure with the latest Flutter Android template.

Fixes #390.

💚 How did you test it?

  • cd example/android && ./gradlew help --no-daemon --console=plain
  • cd example/android && ./gradlew :app:compileDebugKotlin --no-daemon --console=plain
  • cd example/android && ./gradlew :app:assembleRelease --no-daemon --console=plain
  • cd example/android && ./gradlew build --dry-run --no-daemon --console=plain
  • cd example && flutter build apk --release
  • Verified posthog_flutter/android Gradle configuration with AGP 8.11.1 using Gradle 8.14 and an injected Flutter compileSdkVersion property

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

Comment thread pubspec.lock Outdated
Comment thread posthog_flutter/android/build.gradle Outdated
Comment thread example/android/app/build.gradle
@marandaneto
Copy link
Copy Markdown
Member Author

Fixed the release Kotlin target mismatch in 79fdc59 by configuring all KotlinCompile tasks to use JVM 1.8 for both the AGP 9 example app and the plugin's AGP 7/8 path. Also added the missing example ProGuard rules file required by AGP 9 release minification. Verified :app:assembleRelease now passes.

@marandaneto
Copy link
Copy Markdown
Member Author

Pushed f94acba to explicitly keep built-in Kotlin enabled for the migrated example app. Flutter 3.44's migrator otherwise appends android.builtInKotlin=false, which opts the example back out of the migration. I verified release assembly with built-in Kotlin enabled, including with a stale ignored GeneratedPluginRegistrant.java present locally.

@marandaneto
Copy link
Copy Markdown
Member Author

Fixed the Flutter APK lookup failure in 8f7acfb. The Gradle 9 layout.buildDirectory migration was resolving to example/android/build instead of example/build; changed it to ../../build so Flutter finds build/app/outputs/flutter-apk/app-release.apk again. Verified with cd example && flutter build apk --release.

Comment thread posthog_flutter/android/build.gradle
@marandaneto marandaneto marked this pull request as ready for review May 22, 2026 11:42
@marandaneto marandaneto requested a review from a team as a code owner May 22, 2026 11:42
Comment thread posthog_flutter/android/build.gradle
Comment thread .changeset/quiet-ducks-build.md Outdated
Co-authored-by: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com>
@marandaneto marandaneto enabled auto-merge (squash) May 22, 2026 12:49
@marandaneto marandaneto merged commit cfcab97 into main May 22, 2026
19 checks passed
@marandaneto marandaneto deleted the chore/agp9-example-migration branch May 22, 2026 12:54
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.

Migrate Plugin to Built-in Kotlin

2 participants