Skip to content
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

[Bug]: App crashes on setting "coreLibraryDesugaringEnabled" flag as true in build.gradle file #1719

Closed
7 tasks done
VijayMeenaRI opened this issue Apr 26, 2023 · 1 comment
Labels
bug Something isn't working triage

Comments

@VijayMeenaRI
Copy link

VijayMeenaRI commented Apr 26, 2023

Platform

Android 12

Plugin

android_alarm_manager_plus

Version

2.1.2

Flutter SDK

3.7.12

Steps to reproduce

  1. Enable coreLibraryDesugaringEnabled flag to true in app/build.gradle file in compileOptions section.
  2. Add coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' as dependency.
  3. Add android_alarm_manager_plus: ^2.1.2 and do necessary configuration.
  4. App crashes when we enable coreLibraryDesugaringEnabled flag to true.

Code Sample

app/build.gradle file
    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
   
    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
    }

main.dart

import 'dart:isolate';

import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
import 'package:flutter/material.dart';

@pragma('vm:entry-point')
void printHello() {
  final DateTime now = DateTime.now();
  final int isolateId = Isolate.current.hashCode;
  print("[$now] Hello, world! isolate=${isolateId} function='$printHello'");
}

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await AndroidAlarmManager.initialize();
  runApp(const MyApp());
  final int helloAlarmID = 0;
  await AndroidAlarmManager.periodic(
      const Duration(minutes: 1), helloAlarmID, printHello);
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

// This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: const Center(
        child: Text('Hello'),
      ),
    );
  }
}

Logs

C:\Users\Vijay\Downloads\test\flutter_application_1>flutter run --release --verbose
[ +108 ms] executing: [D:\Software\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +37 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
[        ] executing: [D:\Software\flutter/] git tag --points-at 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
[  +46 ms] Exit code 0 from: git tag --points-at 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
[        ] 3.7.12
[   +8 ms] executing: [D:\Software\flutter/] git rev-parse --abbrev-ref --symbolic @{upstream}
[  +30 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{upstream}
[        ] origin/stable

[        ] Transforming lifecycle-livedata-core-2.3.1.aar (androidx.lifecycle:lifecycle-livedata-core:2.3.1) with ExtractAarTransform
[        ] Transforming lifecycle-livedata-core-2.3.1.aar (androidx.lifecycle:lifecycle-livedata-core:2.3.1) with AarTransform
[        ] Transforming lifecycle-livedata-core-2.3.1.aar (androidx.lifecycle:lifecycle-livedata-core:2.3.1) with JetifyTransform
[        ] Transforming lifecycle-livedata-core-2.3.1.aar (androidx.lifecycle:lifecycle-livedata-core:2.3.1) with ExtractAarTransform
[        ] Transforming lifecycle-livedata-core-2.3.1.aar (androidx.lifecycle:lifecycle-livedata-core:2.3.1) with AarTransform
[        ] Transforming core-runtime-2.1.0.aar (androidx.arch.core:core-runtime:2.1.0) with JetifyTransform
[        ] Transforming core-runtime-2.1.0.aar (androidx.arch.core:core-runtime:2.1.0) with ExtractAarTransform
[        ] Transforming core-runtime-2.1.0.aar (androidx.arch.core:core-runtime:2.1.0) with AarTransform
[        ] Transforming core-runtime-2.1.0.aar (androidx.arch.core:core-runtime:2.1.0) with JetifyTransform
[        ] Transforming core-runtime-2.1.0.aar (androidx.arch.core:core-runtime:2.1.0) with ExtractAarTransform
[        ] Transforming core-runtime-2.1.0.aar (androidx.arch.core:core-runtime:2.1.0) with AarTransform
[        ] Transforming interpolator-1.0.0.aar (androidx.interpolator:interpolator:1.0.0) with JetifyTransform
[        ] Transforming interpolator-1.0.0.aar (androidx.interpolator:interpolator:1.0.0) with ExtractAarTransform
[        ] Transforming interpolator-1.0.0.aar (androidx.interpolator:interpolator:1.0.0) with AarTransform
[        ] Transforming annotation-experimental-1.1.0.aar (androidx.annotation:annotation-experimental:1.1.0) with JetifyTransform
[        ] Transforming annotation-experimental-1.1.0.aar (androidx.annotation:annotation-experimental:1.1.0) with ExtractAarTransform
[        ] Transforming annotation-experimental-1.1.0.aar (androidx.annotation:annotation-experimental:1.1.0) with AarTransform
[        ] Caching disabled for task ':app:mergeReleaseArtProfile' because:
[        ]   Build cache is disabled
[        ] Skipping task ':app:mergeReleaseArtProfile' as it is up-to-date.
[        ] :app:mergeReleaseArtProfile (Thread[Execution worker Thread 6,5,main]) completed. Took 0.002 secs.
[        ] Resolve mutations for :app:compileReleaseArtProfile (Thread[Execution worker Thread 23,5,main]) started.
[        ] Resolve mutations for :app:compileReleaseArtProfile (Thread[Execution worker Thread 23,5,main]) completed. Took 0.0 secs.
[        ] :app:compileReleaseArtProfile (Thread[Execution worker Thread 19,5,main]) started.
[        ] > Task :app:compileReleaseArtProfile UP-TO-DATE
[        ] Caching disabled for task ':app:compileReleaseArtProfile' because:
[        ]   Build cache is disabled
[        ] Skipping task ':app:compileReleaseArtProfile' as it is up-to-date.
[        ] :app:compileReleaseArtProfile (Thread[Execution worker Thread 19,5,main]) completed. Took 0.0 secs.
[        ] Resolve mutations for :app:compressReleaseAssets (Thread[Execution worker Thread 23,5,main]) started.
[        ] Resolve mutations for :app:compressReleaseAssets (Thread[Execution worker Thread 23,5,main]) completed. Took 0.0 secs.
[        ] :app:compressReleaseAssets (Thread[Execution worker Thread 14,5,main]) started.
[        ] > Task :app:compressReleaseAssets UP-TO-DATE
[        ] Caching disabled for task ':app:compressReleaseAssets' because:
[        ]   Build cache is disabled
[        ] Skipping task ':app:compressReleaseAssets' as it is up-to-date.
[        ] :app:compressReleaseAssets (Thread[Execution worker Thread 14,5,main]) completed. Took 0.001 secs.
[        ] Resolve mutations for :app:processApplicationManifestReleaseForBundle (Thread[Execution worker Thread 23,5,main]) started.
[        ] Resolve mutations for :app:processApplicationManifestReleaseForBundle (Thread[Execution worker Thread 23,5,main]) completed. Took 0.0 secs.
[        ] :app:processApplicationManifestReleaseForBundle (Thread[Execution worker Thread 2,5,main]) started.
[        ] > Task :app:processApplicationManifestReleaseForBundle UP-TO-DATE
[        ] Caching disabled for task ':app:processApplicationManifestReleaseForBundle' because:
[        ]   Build cache is disabled
[        ] Skipping task ':app:processApplicationManifestReleaseForBundle' as it is up-to-date.
[        ] :app:processApplicationManifestReleaseForBundle (Thread[Execution worker Thread 2,5,main]) completed. Took 0.0 secs.
[        ] Resolve mutations for :app:bundleReleaseResources (Thread[Execution worker Thread 23,5,main]) started.
[        ] Resolve mutations for :app:bundleReleaseResources (Thread[Execution worker Thread 23,5,main]) completed. Took 0.0 secs.
[        ] :app:bundleReleaseResources (Thread[Execution worker Thread 3,5,main]) started.
[        ] > Task :app:bundleReleaseResources UP-TO-DATE
[        ] Caching disabled for task ':app:bundleReleaseResources' because:
[        ]   Build cache is disabled
[        ] Skipping task ':app:bundleReleaseResources' as it is up-to-date.
[        ] :app:bundleReleaseResources (Thread[Execution worker Thread 3,5,main]) completed. Took 0.0 secs.
[        ] Resolve mutations for :app:shrinkReleaseRes (Thread[Execution worker Thread 23,5,main]) started.
[        ] Resolve mutations for :app:shrinkReleaseRes (Thread[Execution worker Thread 23,5,main]) completed. Took 0.0 secs.
[        ] :app:shrinkReleaseRes (Thread[Execution worker Thread 6,5,main]) started.
[        ] > Task :app:shrinkReleaseRes UP-TO-DATE
[        ] Caching disabled for task ':app:shrinkReleaseRes' because:
[        ]   Build cache is disabled
[        ] Skipping task ':app:shrinkReleaseRes' as it is up-to-date.
[        ] :app:shrinkReleaseRes (Thread[Execution worker Thread 6,5,main]) completed. Took 0.0 secs.
[        ] Resolve mutations for :app:optimizeReleaseResources (Thread[Execution worker Thread 23,5,main]) started.
[        ] Resolve mutations for :app:optimizeReleaseResources (Thread[Execution worker Thread 23,5,main]) completed. Took 0.0 secs.
[        ] :app:optimizeReleaseResources (Thread[Execution worker Thread 14,5,main]) started.
[        ] > Task :app:optimizeReleaseResources UP-TO-DATE
[        ] Caching disabled for task ':app:optimizeReleaseResources' because:
[        ]   Build cache is disabled
[        ] Skipping task ':app:optimizeReleaseResources' as it is up-to-date.
[        ] :app:optimizeReleaseResources (Thread[Execution worker Thread 14,5,main]) completed. Took 0.0 secs.
[        ] Resolve mutations for :app:collectReleaseDependencies (Thread[Execution worker Thread 23,5,main]) started.
[        ] Resolve mutations for :app:collectReleaseDependencies (Thread[Execution worker Thread 23,5,main]) completed. Took 0.0 secs.
[        ] :app:collectReleaseDependencies (Thread[Execution worker Thread 14,5,main]) started.
[        ] > Task :app:collectReleaseDependencies UP-TO-DATE
[        ] Caching disabled for task ':app:collectReleaseDependencies' because:
[        ]   Build cache is disabled
[        ] Skipping task ':app:collectReleaseDependencies' as it is up-to-date.
[        ] :app:collectReleaseDependencies (Thread[Execution worker Thread 14,5,main]) completed. Took 0.0 secs.
[        ] Resolve mutations for :app:sdkReleaseDependencyData (Thread[Execution worker Thread 23,5,main]) started.
[        ] Resolve mutations for :app:sdkReleaseDependencyData (Thread[Execution worker Thread 23,5,main]) completed. Took 0.0 secs.
[        ] :app:sdkReleaseDependencyData (Thread[Execution worker Thread 5,5,main]) started.
[        ] > Task :app:sdkReleaseDependencyData UP-TO-DATE
[        ] Caching disabled for task ':app:sdkReleaseDependencyData' because:
[        ]   Build cache is disabled
[        ] Skipping task ':app:sdkReleaseDependencyData' as it is up-to-date.
[        ] :app:sdkReleaseDependencyData (Thread[Execution worker Thread 5,5,main]) completed. Took 0.0 secs.
[        ] Resolve mutations for :app:validateSigningRelease (Thread[Execution worker Thread 23,5,main]) started.
[        ] Resolve mutations for :app:validateSigningRelease (Thread[Execution worker Thread 23,5,main]) completed. Took 0.0 secs.
[        ] :app:validateSigningRelease (Thread[Execution worker Thread 4,5,main]) started.
[        ] > Task :app:validateSigningRelease UP-TO-DATE

[   +2 ms] Stopping app 'app-release.apk' on sdk gphone64 x86 64.
[        ] executing: D:\Software\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell am force-stop com.example.flutter_application_1
[  +66 ms] executing: D:\Software\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell pm list packages com.example.flutter_application_1
[ +117 ms] package:com.example.flutter_application_1
[   +1 ms] executing: D:\Software\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell cat /data/local/tmp/sky.com.example.flutter_application_1.sha1
[  +41 ms] 02c92b39aacdf6e9d51c36b7dfbf8359fe5b92f1
[        ] Latest build already installed.
[        ] executing: D:\Software\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x20000000 --ez enable-dart-profiling true
com.example.flutter_application_1/com.example.flutter_application_1.MainActivity
[  +42 ms] Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x20000000 cmp=com.example.flutter_application_1/.MainActivity (has extras) }
[   +1 ms] Application running.
[   +1 ms] Flutter run key commands.
[        ] h List all available interactive commands.
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[ +211 ms] I/FlutterBackgroundExecutor( 9029): Starting AlarmService...
[+105075 ms] I/FlutterBackgroundExecutor( 9292): Starting AlarmService...
[ +128 ms] I/flutter ( 9292): [2023-04-26 10:48:48.443910] Hello, world! isolate=768906537 function='Closure: () => void from Function 'printHello': static.'

Logs from Logcat

2023-04-26 10:50:34.286  9739-9739  AndroidRuntime          com.example.flutter_application_1    E  FATAL EXCEPTION: main
                                                                                                    Process: com.example.flutter_application_1, PID: 9739
                                                                                                    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)
                                                                                                    	at androidx.window.layout.ExtensionWindowLayoutInfoBackend.registerLayoutChangeCallback(Unknown Source:64)
                                                                                                    	at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invokeSuspend(Unknown Source:89)
                                                                                                    	at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invoke(Unknown Source:8)
                                                                                                    	at androidx.window.layout.WindowInfoTrackerImpl$windowLayoutInfo$1.invoke(Unknown Source:4)
                                                                                                    	at u1.f.b(Unknown Source:2)
                                                                                                    	at u1.a.a(Unknown Source:71)
                                                                                                    	at androidx.window.java.layout.WindowInfoTrackerCallbackAdapter$addListener$1$1.invokeSuspend(Unknown Source:37)
                                                                                                    	at kotlin.coroutines.jvm.internal.a.resumeWith(Unknown Source:11)
                                                                                                    	at r1.o0.run(Unknown Source:88)
                                                                                                    	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:7870)
                                                                                                    	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)
2023-04-26 10:50:34.290   376-376   RanchuHwc               and...graphics.composer@2.4-service  W  validateDisplay: layer 528 CompositionType 1, fallback
2023-04-26 10:50:34.291   579-859   ActivityTaskManager     system_process                       W    Force finishing activity com.example.flutter_application_1/.MainActivity
2023-04-26 10:50:34.292   376-376   RanchuHwc               and...graphics.composer@2.4-service  W  presentDisplay display has no layers to compose, flushing client target buffer.

Flutter Doctor

[√] Flutter (Channel stable, 3.7.12, on Microsoft Windows [Version 10.0.22621.1555], locale en-IN)
    • Flutter version 3.7.12 on channel stable at D:\Software\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4d9e56e694 (8 days ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at D:\Software\Android\Sdk
    • Platform android-33-ext4, build-tools 33.0.1
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

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

    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)

[√] VS Code (version 1.77.3)
    • VS Code at C:\Users\Vijay\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.62.0

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 12 (API 32) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.1555]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 112.0.5615.138
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 112.0.1722.58

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

! Doctor found issues in 1 category.

Checklist before submitting a bug

  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project
@VijayMeenaRI VijayMeenaRI added bug Something isn't working triage labels Apr 26, 2023
@vbuberen
Copy link
Collaborator

This is not a bug of alarm_manager_plus.
See flutter/flutter#110658 and add window dependency as well into your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

2 participants