-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
alarm_manager plugin stopped working (Could not launch engine in configuration) #17566
Comments
as @gazialankus mentioned I also can confirm that downgrading Flutter to v0.2.4 3352a3f will make it work again |
of course using v0.2.4 is no fun at all...constantly getting error like this:
I feel quite alone since no-one really seems to care for this... |
I see this too. Sad to not have this in a functional state, it is a total blocker for me using flutter. |
this issue seems to be related to the changes introduced in the flutter engine with this change (Support multiple shells in a single process). This change by core contributer @chinmaygarde is pretty substantial (changed lines +12,543 −11,072).
BTW I settled on using v0.2.11 since this is the last release that does not contain those changes to the engine. and v0.2.4 is no fun since it gives you tons of errors when omitting the |
cc @zanderso |
Here's my current workaround for this bug FWIW: I'm writing my message to a file in the Android side, and letting the Dart side know via runFromBundle() call as method channels won't work. This is my Kotlin function that does this:
And at the Dart side I have an incomingMsgToDart() that catches this. Ugly but saves the day. May unblock @squashmode. Btw, even at v0.2.4 I'm having this issue with a sticky persistent Android service. AlarmService is fine in v0.2.4 but mine is not. I should create a separate bug report for it at some point with sample code. |
@gazialankus how do you trigger your function |
No I don't poll it, I trigger it with the code that I gave. The The |
see here also: #16998 |
@mravn-google sorry to ping you again but you seem to be the only one who considers that this might be a huge problem. Can you confirm that the current flutter version is broken for any kind of
I'd consider it so important that it ought to be included into some kind of regression test suite. No flutter release should pass as long as this test breaks. |
@marcmo AFAIK, @zanderso cc'ed above is still the primary person working on this. The cc was sent three days ago, and given that today is Monday and Memorial Day in the US, we probably just need to give it a bit more time. I'll be checking up on this issue in the coming days. FWIW, I fully agree that plugins should be regression tested. It is on my plate to set that up. |
I am going to take a look at the regression tomorrow. |
@chinmaygarde did you get around to look at the regression? |
hey google guys, what's the best way to talk to you about this issue? I don't know why you don't consider this issue at all...sure you are busy but come on... this is really embarrassing! don't just focus on the pretty UI stuff, get your base right for an awesome dev experience! flutter is awesome but it is NOT ready for production when you slip with things like that and don't even talk to your users about it! even the react native guys are more responsive in this area! sorry for whining but it is kind of frustrating... |
@marcmo Sorry for the frustration this causes. The best way to talk to us is what you are doing. I'll see if I can find a quick way of unblocking you. No promises though. |
Yep, I agree. Would really like to get more love for this. I have a project in mind, but I can't start working on it unless this is fixed. |
The immediate problem with the |
thanks @mravn-google
without the additional check I'm back to this error
|
@marcmo It's due to the call to
which will clearly prevent execution if the Application is currently running. The background task works only if the Application is not running, and thus |
I built a library based on this one, however using the Android Job Scheduler API instead of AlarmManager, and implementing the approach outlined above (See here). @chinmaygarde do you want me to merge these changes back into android_alarm_manager? |
thanks for your comments @talkdirty . I gave up on using the flutter |
Hi all, I wasn't aware there was an issue filed for this, but I'll take over now since I'm currently working on getting the background execution for Android on par with the iOS implementation. As already mentioned, there was a major refactor of the engine which caused breakages for our background execution implementations. Some of the changes have added the restriction that an isolate spawned by the engine can only have its entry point run once, which is part of the reason that the For this to work, the iOS implementation needs to land and the plugin needs to be restructured slightly so that Dart callbacks can be invoked from the plugin via Unfortunately, these changes may require some code to be updated if the On the upside, callbacks no longer have to be defined as a top-level function in the root library of the application. Instead, callbacks can live in any library available to the application and can be top-level functions or static methods, (closures will probably work, but I'll need to double check), which should hopefully make these sorts of plugins more friendly to use. TL;DR: I'm working on this, although there may be some minor breaking changes for those using the plugin to update UI. This is my top priority and I hope to have something done in the next couple of weeks. |
thanks very much for the update @bkonyi 💚 ! While I was able to get around the |
I've got java.lang.AssertionError: This Flutter engine instance is already running an application error when using this plugin , how can I fix this error , any workaround ? |
@LyCharlie |
flutter doctor -v [✓] Android toolchain - develop for Android devices (Android SDK 27.0.3) [!] iOS toolchain - develop for iOS devices (Xcode 9.4.1) [✓] Android Studio (version 3.1) [!] IntelliJ IDEA Community Edition (version 2017.2.4) [!] VS Code (version 1.25.1) [!] Connected devices ! Doctor found issues in 4 categories. @zoechi thanks |
@LyCharlie there was some work done recently that I think is related. |
@LyCharlie, @zoechi is right, the plugin needs to be updated after flutter/engine#5640 lands. The work is all done in flutter/plugins#642, so hopefully this is all done in the next week. If you're really desperate for this, all the code is there if you're willing to checkout the working branches and use a local engine, but you're probably best off just waiting a few more days for this to be rolled into flutter/flutter's master branch :) |
@bkonyi thanks a lot , I'll try it next week |
@bkonyi @LyCharlie Is there any update ? And is a simple example working for anybody? studio
doctor
|
@zoutepopcorn the fix hasn't landed quite yet as we've been blocked on getting the Android background execution changes in, but those just landed in flutter/engine#5954. Assuming those changes stick, flutter/plugins#642 needs to be approved, landed, and updated on pub. We're almost done, hang in there just a bit longer! |
@mravn-google, would you mind publishing the latest update for this plugin on pub? I don't believe I have publish rights. |
Version 0.2.0 is now available on pub. |
just saw that you updated the plugin. thanks for taking care of this @bkonyi ! one question: how can I make sure I run the matching flutter engine version that contains the changes that go along with the plugin update? |
@marcmo not a problem! Since new functionality added to the engine is needed to use the plugin, you'll want to use either whatever engine revision is being used on |
ok thanks! will start with master first and try to get the example running. again...so awesome you took care of this @bkonyi ! will try to use this rather then my homegrown workaround for android! |
Thanks for all the work 🥇 all. First it was not working that well at my Emulator (not able / time to debug that). But when I tried on my real device it seems to work a lot better 👍 . So I made my own little website to debug. If you want you can use it also (sometimes it has to wake up -
Then I watch the requests on ``https://h0i.herokuapp.com/```. If you want you can use it. It look like after a while (when I lock my screen) it switch from every 5 seconds to every 30 seconds to 1 sometimes minute. Not sure if its an issue, it can be my server also. Just wondering if i can get it stable |
@zoutepopcorn glad I could help! How often are you trying to send requests to your server? The |
@bkonyi thank you for your response. I want to use it for a get request each 3 hours. For testing I made a short timer, but make it longer. I wonder if it's also working in doze mode https://developer.android.com/training/scheduling/alarms
I don't know much about Android but maybe this is a problem.. I will try to replace manager.set(clock, startMillis, pendingIntent); With |
In I changed the function manager.set() => manager.setAndAllowWhileIdle(clock, startMillis, pendingIntent). Now its also working in the background 👍 (only small test). But restarting is not working at the moment, have to look that up later. You can change this in your .....
} else {
manager.setAndAllowWhileIdle(clock, startMillis, pendingIntent);
} Then I will call and do a second call in the doGet() function. await AndroidAlarmManager.oneShot(const Duration(seconds: 10), oneShotID, doGet); |
The issue revolves around: @Override
public void registerWith(PluginRegistry registry) {
GeneratedPluginRegistrant.registerWith(registry);
} from you android Application class. In my case, Some of the plugins generated inside Now looking like this: @Override
public void registerWith(PluginRegistry registry) {
//GeneratedPluginRegistrant.registerWith(registry);
AndroidAlarmManagerPlugin.registerWith(registry.registrarFor("io.flutter.plugins.androidalarmmanager.AndroidAlarmManagerPlugin"));
FlutterLocalNotificationsPlugin.registerWith(registry.registrarFor("com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"));
PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"));
} ETC cheers!!! |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to Reproduce
alarm_manager
plugin example (from folder packages/android_alarm_manager/example)I had this one running before but now cannot get it to work anymore. I can build & deploy the example app to an Android Nexus 5. The app starts without errors. The alarm_manager example is supposed to callback to the dart code every 60 seconds, instead what I see is an error every 60 seconds:
Logs
flutter analyze
flutter doctor -v
The text was updated successfully, but these errors were encountered: