flutter_tools/gradle: dependency_version_checker.gradle.kts references non-existent com.android.Version class`
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Steps to reproduce
### Steps to reproduce
1. `flutter build apk --debug` (or `assembleDebug` directly) any Android
project on Flutter 3.44.1 (stable), building from a local Flutter SDK
checkout on Windows.
### Expected results
Gradle configuration succeeds.
### Actual results
The `flutter_tools/gradle` module itself fails to compile with
`Unresolved reference: Version`, before the project's own Gradle files are
even evaluated.
### Root cause
`packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:160`
references `com.android.Version::class.java.name` (and a fallback
`com.android.builder.model.Version::class.java.name`) at **compile time**.
Neither class exists in any real Android Gradle Plugin release — I checked
every AGP jar from 7.3.0 through 8.13.1 byte-for-byte (`unzip -l`) and none
of them ship a `com.android.Version` or `com.android.builder.model.Version`
class. The actual intended usage is via reflection
(`classLoader.loadClass(...)`), so the class doesn't need to be resolvable
at compile time at all — referencing it via `::class` forces the Kotlin
compiler to require it on the compile classpath, which fails.
### Fix
Replace the `::class.java.name` references with plain string literals
(`"com.android.Version"` / `"com.android.builder.model.Version"`), since
the class is only ever loaded reflectively:
\`\`\`kotlin
// before
com.android.Version::class.java.name
// after
"com.android.Version"
### Expected results
Confirmed independent of Gradle version (reproduces on 8.14.4, 9.1.0, 9.3.1) and JDK (18, 24). Verified the fix unblocks compilation of the flutter_tools/gradle module. Happy to open a PR.
### Actual results
C:\DSW\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 3.44.1, on Microsoft Windows [versÆo 10.0.26200.9457], locale pt-BR) [321ms]
• Flutter version 3.44.1 on channel stable at C:\DSW\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 924134a44c (4 months ago), 2026-05-29 12:13:22 -0400
• Engine revision c416acfeb8
• Dart version 3.12.1
• DevTools version 2.57.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[√] Windows Version (Windows 11 or higher, 25H2, 2009) [1.588ms]
[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [927ms]
• Android SDK at C:/Users/luis/AppData/Local/Android/Sdk
• Emulator version 37.1.11.0 (build_id 15917651) (CL:N/A)
• Platform android-CinnamonBun, build-tools 36.0.0
• ANDROID_HOME = C:/Users/luis/AppData/Local/Android/Sdk
• Java binary at: C:\Program Files\Java\jdk-24\bin\java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version Java(TM) SE Runtime Environment (build 24+36-3646)
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/to/windows-android-setup for more details.
[√] Chrome - develop for the web [89ms]
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.19) [88ms]
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.14.36623.8
• Windows 10 SDK version 10.0.26100.0
[√] Connected device (3 available) [237ms]
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [versÆo 10.0.26200.9457]
• Chrome (web) • chrome • web-javascript • Google Chrome 153.0.8010.50
• Edge (web) • edge • web-javascript • Microsoft Edge 153.0.4234.32
[√] Network resources [361ms]
• All expected network resources are available.
! Doctor found issues in 1 category.
Process finished with exit code 0
### Code sample
Code sample
```dart
[Paste your code here]
```
### Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
### Logs
Logs
```console
[Paste your logs here]
```
### Flutter Doctor output
Doctor output
```console
[Paste your output here]
```
Contributor guide
Research direction
Start in packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts at line 160, where the Android version class names are referenced. Replace the compile-time class references with the string names used by the reflective loading, then run flutter build apk --debug or assembleDebug to verify that the flutter_tools/gradle module compiles and Android configuration succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100