question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error running with android_alarm_manager

See original GitHub issue

Added android_alarm_manager package to my project, got this error:

I/AlarmService( 5386): Starting AlarmService...
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): Failed to handle method call
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Looper android.app.Activity.getMainLooper()' on a null object reference
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at com.google.android.gms.common.api.GoogleApi.<init>(Unknown Source:50)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at com.google.android.gms.location.FusedLocationProviderClient.<init>(Unknown Source:8)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Unknown Source:2)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at com.lyokone.location.LocationPlugin.<init>(LocationPlugin.java:95)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at com.lyokone.location.LocationPlugin.registerWith(LocationPlugin.java:116)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:29)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at com.ngsalesrepapp.Application.registerWith(Application.java:19)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at io.flutter.plugins.androidalarmmanager.AlarmService.startAlarmService(AlarmService.java:114)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at io.flutter.plugins.androidalarmmanager.AndroidAlarmManagerPlugin.startService(AndroidAlarmManagerPlugin.java:79)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at io.flutter.plugins.androidalarmmanager.AndroidAlarmManagerPlugin.onMethodCall(AndroidAlarmManagerPlugin.java:52)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at io.flutter.view.FlutterNativeView$PlatformMessageHandlerImpl.handleMessageFromDart(FlutterNativeView.java:188)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:202)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at android.os.MessageQueue.next(MessageQueue.java:325)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at android.app.ActivityThread.main(ActivityThread.java:6541)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
E/MethodChannel#plugins.flutter.io/android_alarm_manager( 5386): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
I/flutter ( 5386): PlatformException(error, Attempt to invoke virtual method 'android.os.Looper android.app.Activity.getMainLooper()' on a null object reference, null)
I/AlarmService( 5386): AlarmService started!
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found
Error -32601 received from application: Method not found

Thought it might be related to https://github.com/flutter/plugins/pull/1255 which I had a while back. However, after removing each package one at a time I found that the location package was causing this. I recreated the error/issue in a new project with only android_alarm_manager and the location package installed. I have a quite a number of other packages installed that don’t cause any issues. Here is my flutter doctor:

[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17134.648], locale en-ZA) [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [√] Android Studio (version 3.3) [√] Android Studio (version 3.0) [√] IntelliJ IDEA Community Edition (version 2018.3) [√] VS Code (version 1.32.3) [√] Connected device (1 available)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ehhccommented, Apr 11, 2019

Thanks a lot for your quick response & releasing it so soon again

0reactions
bkonyicommented, Nov 1, 2019

FYI @Lyokone, #162 will prevent crashing when a plugin with background execution support attempts to register this plugin without an Activity, but will prevent users from using this plugin from the background. You might want to consider utilizing a Context for grabbing the location service and only check activity != null around calls that actually need an Activity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android_alarm_manager not working and error #73152 - GitHub
The app is running but nothing happened when alarm is triggered. The error below is error from my app, i have created application.java...
Read more >
Android Alarm Manager crash Flutter app - runtime exception ...
If you're calling await AndroidAlarmManager.initialize(); before runApp() and a runtime error was thrown, add WidgetsFlutterBinding.
Read more >
[Solved] Flutter android_alarm_manager/plus apps ... - YouTube
In this video, I will show you the wired error which is thrown when you schedule an alarm and close the app. Android...
Read more >
Schedule alarms - Android Developers
Alarms (based on the AlarmManager class) give you a way to perform time-based operations outside the lifetime of your application.
Read more >
Android AlarmManager As Deep As Possible | by Myrick Chow
AlarmManager is a bridge between application and Android system alarm service. It can send a broadcast to your app (which can be completely...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found