New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coreLibraryDesugaringEnabled option in android/app/build.gradle causes immediate flutter crash (java.lang.NoSuchMethod) on Android 12L/13 #110658
Comments
Hi @dickverweij, thanks for filing the issue. The issue is only happening when adding DemoScreen.Recording.2022-08-31.at.22.04.16.mp4Sample codeDefault Flutter counter app: import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
DefaultCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('en'),
],
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: GestureDetector(
onTap: () => FocusScope.of(context).requestFocus(FocusNode()),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text(
'You have pushed the button this many times: ',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
TextFormField(
keyboardType: TextInputType.number,
),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
child: const Icon(Icons.add),
),
);
}
}
Crash logs
flutter doctor -v[✓] Flutter (Channel stable, 3.3.0, on macOS 12.5 21G72 darwin-x64, locale en-EE)
• Flutter version 3.3.0 on channel stable at /Users/huynq/Documents/GitHub/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ffccd96b62 (28 hours ago), 2022-08-29 17:28:57 -0700
• Engine revision 5e9e0e0aa8
• Dart version 2.18.0
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/huynq/Library/Android/sdk
• Platform android-33, build-tools 31.0.0
• ANDROID_HOME = /Users/huynq/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 13E113
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• 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+0-b1504.28-7817840)
[✓] IntelliJ IDEA Community Edition (version 2020.3.3)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• 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
[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
• IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
• 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
[✓] VS Code (version 1.70.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.46.0
[✓] Connected device (3 available)
• iPhone 13 (mobile) • 2526BC1A-435D-4B08-B99C-44B928F2517B • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-4 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 12.5 21G72 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 104.0.5112.101
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
[✓] Flutter (Channel master, 3.1.0-0.0.pre.2592, on macOS 12.5 21G72 darwin-x64, locale en-EE)
• Flutter version 3.1.0-0.0.pre.2592 on channel master at /Users/huynq/Documents/GitHub/flutter_master
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 069f504297 (3 hours ago), 2022-08-30 18:20:09 -0700
• Engine revision 0ef08a8525
• Dart version 2.19.0 (build 2.19.0-152.0.dev)
• DevTools version 2.16.0
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/huynq/Library/Android/sdk
• Platform android-33, build-tools 31.0.0
• ANDROID_HOME = /Users/huynq/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 13E113
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• 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+0-b1504.28-7817840)
[✓] IntelliJ IDEA Community Edition (version 2020.3.3)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• 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
[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
• IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
• 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
[✓] VS Code (version 1.70.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.46.0
[✓] Connected device (3 available)
• iPhone 13 (mobile) • 2526BC1A-435D-4B08-B99C-44B928F2517B • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-4 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 12.5 21G72 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 104.0.5112.101
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
|
Our team has been experiencing exactly this issue for a few weeks now. We've had reports from production users who are using Fold devices who can't open our apps. Samsung has also reached out to us in an effort to resolve this as they probably want a stable environment for their new devices. Our Flutter apps crash on API 32+ running on fold devices (12L) where we use the desugaring library. Our apps use features from desugaring in its core functionality (java.time), so we can't simply disable it. Interestingly, we've found that if we run the Android project directly instead of through Flutter, the crash does not occur. So if you right-click your project > Flutter > Open Android, and you just run it as a normal Android app, there's no crash. Anything where you run it through Flutter (flutter run, flutter build appbundle, etc) will still crash. We updated the native Android project's Gradle version and Gradle Plugin version. I'm unsure if Flutter uses a different Gradle version when executing the build. gradle-wrapper.properties In android/build.gradle: Crash logsjava.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) at androidx.window.layout.ExtensionWindowLayoutInfoBackend.registerLayoutChangeCallback(ExtensionWindowLayoutInfoBackend.kt:68) at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invokeSuspend(WindowInfoTrackerImpl.kt:52) at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invoke(Unknown Source:8) at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invoke(Unknown Source:4) at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61) at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:212) at androidx.window.java.layout.WindowInfoTrackerCallbackAdapter$addListener$1$1.invokeSuspend(WindowInfoTrackerCallbackAdapter.kt:96) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7842) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)flutter doctor -v[√] Flutter (Channel stable, 3.3.0, on Microsoft Windows [Version 10.0.19044.1889], locale en-US) • Flutter version 3.3.0 on channel stable at C:\Development\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ffccd96 (2 days ago), 2022-08-29 17:28:57 -0700 • Engine revision 5e9e0e0aa8 • Dart version 2.18.0 • DevTools version 2.15.0[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) |
try adding this into your build.gradle.
|
Thank you @arlakay. This worked for us and resolves the crash issue. |
Thanks @arlakay!. What was causing the issue btw? |
Try to add these lines of code to your's build.gradle:
https://developer.android.com/jetpack/androidx/releases/window and optionally:
|
It's about make your app fold aware. |
I believe that this bug affects also non-foldable devices. I had a similar crash on Samsung s22 ultra (not foldable without considerable force) and explicitly adding these |
The following line fixed my crash on my Android emulator API 33.
|
https://stackoverflow.com/a/74410353/17742614 describes the root cause of the issue. Adding dependencies {
implementation 'androidx.window:window:1.0.0'
implementation 'androidx.window:window-java:1.0.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
} |
It sounds like the fix is that Flutter should update the version of It looks like we're currently pulling in 1.0.0-beta04, after it was updated from 1.0.0-beta03 in flutter/engine#29897 . So that should be bumped to at least 1.0.0, and perhaps even to 1.1.0-rc01, the latest. I'm actually still a bit puzzled at how a version bump to 1.0.0 fixes the issue — I'd have expected it to require bumping to at least 1.1.0-alpha01, because that's the first release that has the commit that looks to be the fix. But based on several reports above, it seems like a version bump to 1.0.0 does fix it. Details on the apparent upstream fix and where it was released: I don't entirely understand what's going on in the issue as diagnosed in that StackOverflow answer, but it looks like probably an accurate diagnosis. In particular, here's the stack trace @huycozy found above:
and that answer points to an upstream AndroidX commit d9a44f767 that fixed a bug in From the The thing that leaves me still puzzled, though, is that the workaround reported above is to force the |
This comment was marked as off-topic.
This comment was marked as off-topic.
Shouldn't this be closed as it's been merged into flutter? |
After following this, I still got the crash many times and lost many hours. So, this doesn't work |
@huycozy This just happened to me when submitting to Google Play. I have recently added desugaring due to a requirement from flutter_local_notifications but since I thought this was fixed in Flutter, I had not added the extra dependencies in my gradle file. So, at least for me, this issue persists in Flutter 3.16.1 and happened on a Pixel 2 on Google Play. Now I will try to add the gradle dependences as suggested above but if this is expected to not happen on recent flutter versions, then there might still be something wrong. Flutter 3.16.1
|
This comment was marked as off-topic.
This comment was marked as off-topic.
No, there's been no change merged into Flutter to fix this. The |
Seems strange that it hasn't been fixed yet... |
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.
add dependency
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
Logs
The text was updated successfully, but these errors were encountered: