Repository navigation
Description
Steps to reproduce
- Run flutter pub upgrade.
- Try to build the Android project using flutter build apk
-
Where:
Build file '/Users/--/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.3/android/build.gradle.kts' line: 28 -
What went wrong:
Script compilation error:Line 28: compileSdk = flutter.compileSdkVersion
^ Unresolved reference: compileSdkVersion
1 error
Expected results
The Android project should compile successfully without errors.
Actual results
When attempting to build the Android project, the build process fails during the execution of the Kotlin Gradle script inside the flutter_plugin_android_lifecycle plugin. The build stops with the following error:
-
Where:
Build file '/Users/ec2-user/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.3/android/build.gradle.kts' line: 28 -
What went wrong:
Script compilation error:Line 28: compileSdk = flutter.compileSdkVersion
^ Unresolved reference: compileSdkVersion
1 error
Code sample
Code sample
N/A
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
Flutter (Channel stable, 3.38.4, on macOS 15.0 24A335 darwin-arm64, locale en-US) [648ms]
• Flutter version 3.38.4 on channel stable at /Users/ec2-user/fvm/versions/3.38.4
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 66dd93f9a2 (4 months ago), 2025-12-03 14:56:10 -0800
• Engine revision a5cb96369e
• Dart version 3.10.3
• DevTools version 2.51.1
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging
Activity
vitormesquita-web commentedon Mar 25, 2026
The same issue is also happening with other Android plugins after the update this morning:
All of them fail to build with the same Gradle Kotlin script error related to:
Unresolved reference: compileSdkVersionmbcorona commentedon Mar 26, 2026
Hi @vitormesquita-web , thanks for the report. The latest plugin updates migrated to Kotlin DSL (build.gradle.kts) but appear to be missing the minimum Flutter SDK version constraints in their pubspec.yaml. This causes pub upgrade to incorrectly pull them on older SDKs like 3.38.4, breaking the build.
I am routing this to the Android and Ecosystem teams to update the version constraints.
Workaround: Until patched, either upgrade your Flutter SDK to the latest stable release.
flutter-triage-bot commentedon Mar 26, 2026
Issue is assigned to multiple teams (ecosystem, android). Please ensure the issue has only one
team-*label at a time. Usefyi-*labels to have another team look at the issue without reassigning it.BoboBirdFly commentedon Mar 26, 2026
same problem, works for me if i overrides these: path_provider_foundation: 2.4.4
flutter_plugin_android_lifecycle: 2.0.33
path_provider_android: 2.2.22
url_launcher_android: 6.3.28
video_player_android: 2.9.4
webview_flutter_android: 4.10.13
13 remaining items
lemonliu2023 commentedon Apr 29, 2026
我的解决方案:
改动在 moa-android/build.gradle (line 33):
plugins {
id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
}
原因:新版 Flutter Android 插件依赖 flutter.compileSdkVersion,但当前宿主工程是旧式 Flutter module 接入,Kotlin DSL 插件脚本在编译时拿不到 FlutterExtension 类型。把 Flutter Gradle plugin 放到宿主工程 classpath 上但不应用,可以让插件脚本正确解析这个 extension。
j-ixcayau commentedon May 11, 2026
Still reproducing on Flutter 3.41.9 (stable) in an add-to-app setup (Flutter module embedded via
include_flutter.groovyinto a Kotlin Android host).Removing all our pinned Groovy plugin versions and running
flutter pub upgradepulls incamera_android_camerax 0.7.2(the first KTS version)../gradlew assembleDebugthen fails with:e: …/camera_android_camerax-0.7.2/android/build.gradle.kts:40:26: Unresolved reference: compileSdkVersion
FAILURE: Build failed with an exception.
What went wrong: Script compilation error: Line 40: compileSdk = flutter.compileSdkVersion ^ Unresolved reference: compileSdkVersion
The
flutterextension thatbuild.gradle.ktsreferences isn't exposed when the plugin is consumed throughinclude_flutter.groovy(add-to-app), only when consumed through the standalone Flutter Android Gradle plugin.Current workaround in our root
pubspec.yaml— pinning every affected plugin to its last Groovy release:This works but blocks us from picking up newer fixes/features in any of those plugins. Would be great to see a path forward — either exposing flutter.compileSdkVersion to add-to-app Kotlin DSL, or making the plugins fall back to a sensible compile SDK when the extension isn't available.
github-actions commentedon May 12, 2026
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.
github-actions commentedon May 26, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.jesswrd commentedon Jun 23, 2026
Looks like someone else was able to repro and has a workaround: #188339. Let me see if I can repro this.
github-actions commentedon Jul 21, 2026
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.
G0retZ commentedon Jul 28, 2026
I experience the same issue in my add-to-app flutter scenario.
Looks like the issue is a difference in how KTS and Groovy script work. AI summary:
Hope this will help with the issue investigation.
github-actions commentedon Aug 11, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.