Skip to content

Android: move the example app to AGP 9 and Gradle 9.6 #920

Description

@gabbopalma

Three dependabot PRs are blocked on the same wall, and closing them one by one without writing the reason down means rediscovering it every month. This issue is that reason, plus what has to happen before any of them can land.

The plugin itself is already AGP 9 compatible as of #914. What is blocked is the example app, and the Gradle version that comes with it.

Gradle 9.6 needs AGP 9, everywhere

AGP 8.x relies on org.gradle.api.problems.internal.InternalProblems, which Gradle removed in 9.6.0. Any project on AGP 8 fails at configuration time under Gradle 9.6.x:

> Failed to apply plugin 'com.android.internal.library'.
   > Plugin 'com.android.internal.library' relies on
     'org.gradle.api.problems.internal.InternalProblems', a Gradle internal API
     that was removed in Gradle 9.6.0. Update the plugin to a version that no
     longer uses Gradle internal APIs, or use Gradle 9.5.

That is Gradle's own message, and it is version-specific rather than project-specific. It rules out both wrapper bumps:

cd maplibre_gl/android
java -cp gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain help

which fails with the message above. Worth remembering that a green check on maplibre_gl/android/gradle/wrapper means very little today.

There is no intermediate step to take: 9.5.1 is the newest 9.5.x, and the next published versions are 9.6.0 and 9.6.1.

What blocks the example app on AGP 9 (#904)

Four things, none of them in this repository:

  1. Flutter 3.44.0's own Gradle plugin throws a NullPointerException on AGP 9's new DSL. Needs android.newDsl=false, which the Flutter migrator adds automatically.
  2. Past that, device_info_plus 12.3.0 does not declare compileSdk, which AGP 9 requires of every module.
  3. Newer device_info_plus and permission_handler_android do declare it, but compile against Android SDK 37. See chore(example): hold permission_handler at 12.x #913 for how that plays out.
  4. file_picker and share_plus 12 still apply the Kotlin Gradle Plugin.

So the example cannot move until those plugins move, and the wrapper bumps cannot move until the example does.

Also waiting here

#803 wants androidx.core:core-ktx 1.19.0, whose AAR metadata declares minCompileSdk=37 and minAndroidGradlePluginVersion=9.1.0. Since checkAarMetadata runs in the consuming app, taking it would force every app using this plugin onto compileSdk 37 and AGP 9.1. #919 takes 1.18.0 instead, which declares exactly what 1.17.0 already declares. 1.19.0 comes back into scope once this issue is resolved.

Order of work

  1. The plugin builds under AGP 9 already (build(android): apply the Kotlin Gradle Plugin only below AGP 9 #914), verified with AGP 9.3.1, Gradle 9.6.1 and built-in Kotlin: :maplibre_gl:compileDebugKotlin, :maplibre_gl:compileDebugJavaWithJavac and :maplibre_gl:bundleDebugAar all succeed.
  2. The example app moves to AGP 9 once its plugin dependencies allow it, which also decides the device_info_plus question.
  3. Then the wrapper bumps (chore(deps): bump gradle-wrapper from 9.5.1 to 9.6.1 in /maplibre_gl_example/android #883, chore(deps): bump gradle-wrapper from 9.5.1 to 9.6.1 in /maplibre_gl/android #884) and androidx.core 1.19.0 (chore(deps): bump androidx.core:core-ktx from 1.17.0 to 1.19.0 in /maplibre_gl/android in the androidx-core group across 1 directory #803) become one-line changes.
  4. maplibre_gl/android/build.gradle can then drop the agpMajor < 9 condition added in build(android): apply the Kotlin Gradle Plugin only below AGP 9 #914 and apply nothing, which is the shape the Flutter guide documents.

Also open, and worth settling here: whether .github/dependabot.yml should hold com.android.application, the Gradle wrapper and androidx.core until then, rather than reopening the same three PRs on every release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions