website icon indicating copy to clipboard operation
website copied to clipboard

Describe where to find {kotlinVersion} and {agpVersion} values in 'Deprecated imperative apply of Flutter's Gradle plugins' page

Open buck-ross opened this issue 1 year ago • 5 comments

Page URL

https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply/

Page source

https://github.com/flutter/website/tree/main/src/release/breaking-changes/flutter-gradle-plugin-apply.md

Describe the problem

On the page, the migration process includes the following quote:

Replace the contents of /android/settings.gradle with the below, remembering to replace {agpVersion} and {kotlinVersion} with previously used values

While {kotlinVersion} can be found easily enough from the buildScript section of build.gradle, it is extremely unclear where {agpVersion} can be found, as it is does not appear to be present in any configuration file anywhere. This makes these migration instructions effectively unusable.

Expected fix

The source of the {kotlinVersion} and {agpVersion} values must be described within the migration instructions.

Additional context

Here is my original settings.gradle file:

include ':app'

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

As you can see, the "previously used values" cannot be easily determined by looking at this file.

I would like to fix this problem.

  • [ ] I will try and fix this problem on docs.flutter.dev.

buck-ross avatar Jan 27 '24 18:01 buck-ross

NOTE: I would happily submit a PR to fix this problem myself, except for the fact that I still haven't found {agpVersion} for my own project.

buck-ross avatar Jan 27 '24 18:01 buck-ross

Hi @buck-ross You can find agpVersion in the same file /android/build.gradle where your kotlinVersion is declared. For eg in my project:

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

It's using AGP version 7.3.1. Can you check if it exists in your project?

huycozy avatar Jan 29 '24 11:01 huycozy

I ended up scrapping my old code and completely rebuilding the project, so I no longer have that file. However, I think I remember seeing something similar to that line. I still think the documentation needs clarification, since it may not be clear to the average use that agpVersion refers to com.android.tools.build:gradle.

At this point, I've managed to move past this issue, so if you disagree with my assessment on the need for clarification, feel free to close this issue.

buck-ross avatar Feb 13 '24 02:02 buck-ross

Sorry for the late response. Yes, I think previously used values should be more clear on where user can find them.

huycozy avatar Feb 20 '24 09:02 huycozy

If someone was looking to improve the documentation they might expand the agp acronym to be "Android gradle plugin" and link to https://developer.android.com/build/releases/gradle-plugin

reidbaker avatar Feb 23 '24 19:02 reidbaker