How to Fix Core Library Desugaring and Java Version Warnings After Upgrading to Flutter 3.27.3
After upgrading to Flutter 3.27.3, developers may encounter errors related to core library desugaring and Java version compatibility while building APKs or app bundles. This article provides a step-by-step guide to resolve these issues, including enabling core library desugaring, updating Java version settings, and modifying Gradle configurations to ensure a smooth build process.
Dependency ‘:flutter_local_notifications’ requires core library desugaring to be enabled for :app.
Here how, you can fix it quickly:
Add the following in android>app>build.grable
:
compileOptions {
...
coreLibraryDesugaringEnabled true
}
dependencies {
implementation 'androidx.window:window:1.0.0'
implementation 'androidx.window:window-java:1.0.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
}
If you have recently upgraded your Java version to 21, you might be getting these following warnings:
To fix or remove this warning you might need to change the following files:
- In
android/app/build.gradle
:
// change
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
// to
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17
}
In gradle/wrapper/gradle-wrapper.properties
change your distributionUrl
to the following:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
In some cases, you might want to update com.android.application
in android/setting.gradle
file.
id "com.android.application" version "8.5.0" apply false
Conclusion:
Upgrading to Flutter 3.27.3 can introduce challenges related to core library desugaring and Java version compatibility, but these issues can be resolved with a few adjustments to your project’s configuration files. By enabling core library desugaring, updating the Java version settings, and ensuring your Gradle configurations are up-to-date, you can eliminate build errors and warnings. Following these steps will help you maintain a seamless development workflow and keep your Flutter projects running smoothly.
Useful Links
Subscribe to my youtube channel to get more insights!