Skip to content

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

@yanshouwang

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!

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