Skip to content

coreLibraryDesugaringEnabled option in android/app/build.gradle causes immediate flutter crash (java.lang.NoSuchMethod) on Android 12L/13  #110658

@dickverweij

Description

@dickverweij

Steps to Reproduce

this already reported in issues 110000 and 104279 but was not reproducable, now I have a reproducable crash with the plain vanilla counter app.

  1. flutter create z4tester
  2. adjust android/app/build.gradle
  3. enable option
    compileOptions {
        coreLibraryDesugaringEnabled true

        sourceCompatibility JavaVersion.VERSION_1_8

        targetCompatibility JavaVersion.VERSION_1_8
    }

add dependency

   dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}

set min sdk to 21
minSdkVersion 21
5. hook up 12L phone (Galaxy Z4 Fold)
6. Flutter run

Expected results:
normal counter app

Actual results:
app crashed at startup

Code sample
flutter create z4tester (no change to code whatsoever)
Logs
[   +1 ms] Forwarded host port 58322 to device port 34629 for Observatory
[   +5 ms] Caching compiled dill
[  +44 ms] Connecting to service protocol: http://127.0.0.1:58322/ieBP2dHgJdI=/
[  +15 ms] E/AndroidRuntime(26454): FATAL EXCEPTION: main
[        ] E/AndroidRuntime(26454): Process: com.example.z4tester, PID: 26454
[   +2 ms] E/AndroidRuntime(26454): java.lang.NoSuchMethodError: No interface method addWindowLayoutInfoListener(Landroid/app/Activity;Lj$/util/function/Consumer;)V in class
Landroidx/window/extensions/layout/WindowLayoutComponent; or its super classes (declaration of 'androidx.window.extensions.layout.WindowLayoutComponent' appears in /system_ext/framework/androidx.window.extensions.jar)       
[   +1 ms] E/AndroidRuntime(26454):     at androidx.window.layout.ExtensionWindowLayoutInfoBackend.registerLayoutChangeCallback(ExtensionWindowLayoutInfoBackend.kt:68)
[        ] E/AndroidRuntime(26454):     at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invokeSuspend(WindowInfoTrackerImpl.kt:52)
[        ] E/AndroidRuntime(26454):     at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invoke(Unknown Source:8)
[        ] E/AndroidRuntime(26454):     at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invoke(Unknown Source:4)
[        ] E/AndroidRuntime(26454):     at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
[        ] E/AndroidRuntime(26454):     at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:212)
[        ] E/AndroidRuntime(26454):     at androidx.window.java.layout.WindowInfoTrackerCallbackAdapter$addListener$1$1.invokeSuspend(WindowInfoTrackerCallbackAdapter.kt:96)
[        ] E/AndroidRuntime(26454):     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
[        ] E/AndroidRuntime(26454):     at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
[        ] E/AndroidRuntime(26454):     at android.os.Handler.handleCallback(Handler.java:938)
[        ] E/AndroidRuntime(26454):     at android.os.Handler.dispatchMessage(Handler.java:99)
[        ] E/AndroidRuntime(26454):     at android.os.Looper.loopOnce(Looper.java:226)
[        ] E/AndroidRuntime(26454):     at android.os.Looper.loop(Looper.java:313)
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:94:3)
           <asynchronous suspension>
No issues found! (ran in 5.4s)
    • Flutter version 3.0.5 at C:\Development\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (7 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc5)
    • Android SDK at C:\Users\*****\AppData\Local\Android\sdk
    • Platform android-32, build-tools 31.0.0-rc5
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Professional 2019 16.10.2)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
    • Visual Studio Professional 2019 version 16.10.31410.357
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] VS Code, 64-bit edition (version 1.70.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.46.0

[√] Connected device (5 available)
    • SM F936B (mobile)                     • RFCT716Y5HD   • android-arm64  • Android 12 (API 32)
    • Android SDK built for x86 64 (mobile) • emulator-5554 • android-x64    • Android 6.0 (API 23) (emulator)
    • Windows (desktop)                     • windows       • windows-x64    • Microsoft Windows [Version 10.0.22000.856]
    • Chrome (web)                          • chrome        • web-javascript • Google Chrome 104.0.5112.102
    • Edge (web)                            • edge          • web-javascript • Microsoft Edge 104.0.1293.70

[√] HTTP Host Availability
    • All required HTTP hosts are available

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consolec: fatal crashCrashes that terminate the processdependency: androidAndroid team may need to help use: OS-version specificAffects only some versions of the relevant operating systemengineflutter/engine related. See also e: labels.platform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamtriaged-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