flutter_local_notifications
flutter_local_notifications copied to clipboard
Dependency ':flutter_local_notifications' requires core library desugaring to be enabled for :app
Execution failed for task ':app:checkDevDebugAarMetadata'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction An issue was found when checking AAR metadata:
1. Dependency ':flutter_local_notifications' requires core library desugaring to be enabled
for :app.
See https://developer.android.com/studio/write/java8-support.html for more
details.
Hi @here am facing this issue after updating to gradle 8.5.0 version in Android Studio Can anyone help me on this ?
I have got the same issue. The error asks to use this code below
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
but it is deprecated and should not be used.
I also have same issue. gradle:8.2.0
@PollyGlot do you have a link to a repo hosting a minimal app that shows that what is there is deprecated and shouldn't be used? I updated the example app to AGP 8.6.0, built a release APK and didn't see deprecation warnings
same issue solved by adding in app/build.gradle
compileOptions {
......//
coreLibraryDesugaringEnabled true
}
and
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
}
dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2' }
This works !!!
This works !!!
This works because you're setting the desugaring configurations.
The point is: you are using scheduled notifications? If you're not using it, you should not implement this desugaring configurations. As readme says here, we should configure desugaring only if we will use scheduled notifications: https://pub.dev/packages/flutter_local_notifications#gradle-setup
I've commented this in another similar topic: https://github.com/MaikuB/flutter_local_notifications/issues/2405#issuecomment-2466279883
Just to clarify, you should be enabling desugaring whether or not you are using scheduled notifications.
See the next version of the Android setup guide for details, desugaring is right up there
Should I do in my project or modify flutter_local_notifications?
flutter version >= 3.29
path:android/app/build.gradle.kts
android {
compileOptions {
...
isCoreLibraryDesugaringEnabled = true
}
}
and
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
}
It is advisable to avoid using high-level APIs on older versions of Android. maybe need someone's pr to remove coreLibraryDesugaring
I have the same issue
I have same issue. Any update ?
@burakJs this issue happens when desugaring hasn't been enabled and hence why the error says this as well. This is also why there are others in the thread that mentioned the Gradle changes they did the changes to enable it. Those encountering this issue will need to check the readme to follow the instructions as it is called out there as part of the Android setup steps. I'm going to close this as this becoming a longer thread. Should anyone else be posting about this issue, please check the readme first. If you have actually enabled it and then still had an issue then please file a new issue and include a link to a repository hosting a minimal app
flutter version >= 3.29
path:android/app/build.gradle.kts
android { compileOptions { ... isCoreLibraryDesugaringEnabled = true } }and
dependencies { coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4") }
yep, worked!
The notion that a notification library should dictate a build feature level for the user is in my opinion insane. This is the only thing that forces us to use corelibrarydesugaring which increases build time and app size.
agree. It can be divided into two different versions: one with corelibrarydesugaring and one without corelibrarydesugaring. Even learn from Apple: if older versions are no longer supported, then there is no need for corelibrarydesugaring
@ezamelczyk I couldn't find any sources that show a significant, non-negligible cost with desugaring that would justify not having those APIs available. I'm also not sure since when dependencies weren't allowed to affect the build process -- isn't managing dependencies like the whole point of CMake? Flutter code by itself doesn't use more Android APIs, but using plugins does, and so needing to configure settings to get those features is a pretty natural consequence of... using those features.
As mentioned above, I am working on writing some clearer documentation for setting up on all platforms (#2477). That should help with those who are confused as this is actually in the README at the moment.
flutter version >= 3.29
path:android/app/build.gradle.kts
android { compileOptions { ... isCoreLibraryDesugaringEnabled = true } }and
dependencies { coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4") }
after replacing coreLibraryDesugaringEnabled = true to isCoreLibraryDesugaringEnabled = true it work fine
@ezamelczyk I couldn't find any sources that show a significant, non-negligible cost with desugaring that would justify not having those APIs available. I'm also not sure since when dependencies weren't allowed to affect the build process -- isn't managing dependencies like the whole point of CMake? Flutter code by itself doesn't use more Android APIs, but using plugins does, and so needing to configure settings to get those features is a pretty natural consequence of... using those features.
As mentioned above, I am working on writing some clearer documentation for setting up on all platforms (#2477). That should help with those who are confused as this is actually in the README at the moment.
We're using gradle not CMake, and if it were up to me there wouldn't even be flutter in our project but unfortunately higher-ups decided it's cheaper to make some screens in flutter and import them into our existing native app. There's a significant performance impact if one small library in a small module enables desugaring for an almost 1m loc project.