ekasetiawans / flutter_background_service

257 stars 168 forks source link

desugar_jdk_libs crash the build #445

Open guyluz11 opened 2 weeks ago

guyluz11 commented 2 weeks ago

When adding only coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2' as instracted in the readme the app crashes on build Error:

E/AndroidRuntime(13635): FATAL EXCEPTION: main
E/AndroidRuntime(13635): Process: com.haveinfinitehorizons, PID: 13635
E/AndroidRuntime(13635): 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)
E/AndroidRuntime(13635):    at androidx.window.layout.ExtensionWindowLayoutInfoBackend.registerLayoutChangeCallback(ExtensionWindowLayoutInfoBackend.kt:68)
E/AndroidRuntime(13635):    at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invokeSuspend(WindowInfoTrackerImpl.kt:52)
E/AndroidRuntime(13635):    at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invoke(Unknown Source:8)
E/AndroidRuntime(13635):    at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invoke(Unknown Source:4)
E/AndroidRuntime(13635):    at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
E/AndroidRuntime(13635):    at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:230)
E/AndroidRuntime(13635):    at androidx.window.java.layout.WindowInfoTrackerCallbackAdapter$addListener$1$1.invokeSuspend(WindowInfoTrackerCallbackAdapter.kt:96)
E/AndroidRuntime(13635):    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(13635):    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/AndroidRuntime(13635):    at android.os.Handler.handleCallback(Handler.java:958)
E/AndroidRuntime(13635):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(13635):    at android.os.Looper.loopOnce(Looper.java:205)
E/AndroidRuntime(13635):    at android.os.Looper.loop(Looper.java:294)
E/AndroidRuntime(13635):    at android.app.ActivityThread.main(ActivityThread.java:8177)
E/AndroidRuntime(13635):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(13635):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
E/AndroidRuntime(13635):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
E/AndroidRuntime(13635):    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@b267036, android.os.HandlerExecutor@5526b37]
Error connecting to the service protocol: failed to connect to http://127.0.0.1:34151/DzY09DvEaPU=/
the Dart compiler exited unexpectedly.

I have managed to fix that by adding

implementation "com.google.android.material:material:1.9.0"
implementation "androidx.window:window:1.1.0"

to dependencies

dependencies {
    implementation "com.google.android.material:material:1.9.0"
    implementation "androidx.window:window:1.1.0"
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
}
guyluz11 commented 2 weeks ago

Maybe this is also the fix for fix--android-build-error branch.