Skip to content

flutter build message is obsolete when add dependency which need a higher kotlin versioin on Android #144454

Closed

Description

@yanshouwang

Steps to reproduce

  1. Creeate a flutter plugin project.
  2. Add a dependency which need a higher kotlin version in the 'android/build.gradle', eg. 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.8.0'
  3. Run flutter build apk.

Expected results

The build process should failed and show correct warning message about how to upgrade the kotlin version.
Seems the right way to do this is edit the settings.gradle in example/android and change the plugins block.

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.3.0" apply false
    id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

See this related issues

Actual results

The build process failed and show an obsolete warning message about how to upgrade the kotlin version.

BUILD FAILED in 27s
Running Gradle task 'assembleRelease'...                           28.6s

┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin.                            │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update │
│ E:\mlkit\mlkit_barcode_scanning\example\android\build.gradle:                                     │
│ ext.kotlin_version = '<latest-version>'                                                           │
└───────────────────────────────────────────────────────────────────────────────────────────────────┘
Gradle task assembleRelease failed with exit code 1

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
PS E:\mlkit\mlkit_barcode_scanning\example> flutter build apk
Resolving dependencies... 
  leak_tracker 10.0.0 (10.0.4 available)
  leak_tracker_flutter_testing 2.0.1 (3.0.3 available)
  leak_tracker_testing 2.0.1 (3.0.1 available)
  meta 1.11.0 (1.12.0 available)
  test_api 0.6.1 (0.7.0 available)
  vm_service 13.0.0 (14.1.0 available)
Got dependencies!
6 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

注: E:\Pub\Cache\hosted\pub.dev\jni-0.7.2\android\src\main\java\com\github\dart_lang\jni\JniPlugin.java使用或覆盖了已 过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1324 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
e: D:/.gradle/caches/transforms-3/1fc0b5483efdd6081bd0c97620941f82/transformed/jetified-kotlinx-coroutines-core-jvm-1.8.0.jar!/META-INF/kotlinx-coroutines-core.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: D:/.gradle/caches/transforms-3/771c52554f6597a5723d604357369aaa/transformed/jetified-kotlinx-coroutines-play-services-1.8.0.jar!/META-INF/kotlinx-coroutines-play-services.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: D:/.gradle/caches/transforms-3/892bfb75d265c46acfb35324fdd8b854/transformed/jetified-kotlinx-coroutines-android-1.8.0.jar!/META-INF/kotlinx-coroutines-android.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: D:/.gradle/caches/transforms-3/8a5e7dc83c60f95721bff1845f90da65/transformed/jetified-kotlin-stdlib-1.9.21.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: D:/.gradle/caches/transforms-3/8a5e7dc83c60f95721bff1845f90da65/transformed/jetified-kotlin-stdlib-1.9.21.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: D:/.gradle/caches/transforms-3/8a5e7dc83c60f95721bff1845f90da65/transformed/jetified-kotlin-stdlib-1.9.21.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileReleaseKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 27s
Running Gradle task 'assembleRelease'...                           28.6s

┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin.                            │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update │
│ E:\mlkit\mlkit_barcode_scanning\example\android\build.gradle:                                     │
│ ext.kotlin_version = '<latest-version>'                                                           │
└───────────────────────────────────────────────────────────────────────────────────────────────────┘
Gradle task assembleRelease failed with exit code 1

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.1, on Microsoft Windows [Version 10.0.22621.3155], locale zh-CN)
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.5)
[✓] Android Studio (version 2023.1)
[✓] VS Code, 64-bit edition (version 1.86.2)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

Activity

  1. darshankawar commented on Mar 1, 2024

    @darshankawar
    Member

    @yanshouwang
    Can you check this breaking change and see if it helps in your case or not ?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 1, 2024
  3. yanshouwang commented on Mar 1, 2024

    @yanshouwang
    Author

    @darshankawar yes, This is wha't I mean, but the build warning messge tell me to update ext.kotlin_version = '<latest-version>'

    I noticed that the KGP and AGP configurations has movedto the plugins block in app module.

    But seems in the library module(flutter plugin) the KGP still use the old way?

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 1, 2024
  5. yanshouwang commented on Mar 1, 2024

    @yanshouwang
    Author

    @darshankawar Another issue is that flutter has changed the flutter.compileSdkVersion to 34, but the AGP version seems not compitiable with API 34. When sync gradle in Android Studio, the output will warning to upgrade the AGP version:

    We recommend using a newer Android Gradle plugin to use compileSdk = 34
    
    This Android Gradle plugin (7.4.2) was tested up to compileSdk = 33
    
    This warning can be suppressed by adding
        android.suppressUnsupportedCompileSdk=34
    to this project's gradle.properties
    
    The build will continue, but you are strongly encouraged to update your project to
    use a newer Android Gradle Plugin that has been tested with compileSdk = 34
    Update Gradle property to suppress warning
    Affected Modules: app
    

    I think the AGP version should upgrade to 8.0+ to support the flutter.compileSdkVersion=34

  6. darshankawar commented on Mar 4, 2024

    @darshankawar
    Member

    Another issue is that flutter has changed the flutter.compileSdkVersion to 34, but the AGP version seems not compitiable with API 34. When sync gradle in Android Studio, the output will warning to upgrade the AGP version:

    @yanshouwang Please open a new issue for this case and provide relevant details using new issue template so that we can properly address the issue.

  7. darshankawar commented on Mar 4, 2024

    @darshankawar
    Member

    For this issue reported, I was able to replicate the reported behavior using details provided in original description.
    Keeping the issue open for team's tracking / input and expected behavior.

    stable, master flutter doctor -v
    [!] Flutter (Channel stable, 3.19.2, on macOS 12.2.1 21D62 darwin-x64, locale
        en-GB)
        • Flutter version 3.19.2 on channel stable at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7482962148 (5 days ago), 2024-02-27 16:51:22 -0500
        • Engine revision 04817c99c9
        • Dart version 3.3.0
        • DevTools version 2.31.1
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    [!] Flutter (Channel master, 3.20.0-16.0.pre.42, on macOS 12.2.1 21D62
        darwin-x64, locale en-GB)
        • Flutter version 3.20.0-16.0.pre.42 on channel master at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7d5dababd0 (88 minutes ago), 2024-02-29 22:55:15 -0500
        • Engine revision 76140bc9ce
        • Dart version 3.4.0 (build 3.4.0-190.0.dev)
        • DevTools version 2.33.1
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at /Users/dhs/Library/Android/sdk
        ✗ cmdline-tools component is missing
          Run `path/to/sdkmanager --install "cmdline-tools;latest"`
          See https://developer.android.com/studio/command-line for more details.
        ✗ Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for
          more details.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 13C100
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
        • IntelliJ at /Applications/IntelliJ IDEA.app
        • Flutter plugin version 65.1.4
        • Dart plugin version 213.7228
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.29.0
    
    [✓] Connected device (3 available)
        • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios
          • iOS 15.3.1 19D52
        • macOS (desktop)           • macos                                    •
          darwin-x64     • macOS 12.2.1 21D62 darwin-x64
        • Chrome (web)              • chrome                                   •
          web-javascript • Google Chrome 109.0.5414.119
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
          
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    
    
  8. added
    platform-androidAndroid applications specifically
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: buildBuilding flutter applications with the tool
    team-toolOwned by Flutter Tool team
    and removed
    in triagePresently being triaged by the triage team
    on Mar 4, 2024
  9. added
    team-androidOwned by Android platform team
    and removed
    team-toolOwned by Flutter Tool team
    on Mar 5, 2024
  10. added
    P2Important issues not at the top of the work list
    triaged-androidTriaged by Android platform team
    on Mar 28, 2024
  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on Apr 1, 2024
  12. github-actions commented on Apr 15, 2024

    @github-actions

    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 -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: buildBuilding flutter applications with the toolfound in release: 3.19Found to occur in 3.19found in release: 3.20Found to occur in 3.20has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions