Removes Permission?

I will put it on the list. I'm not sure though how quickly we will be able to turn this around.

Edit: I've confirmed the behavior locally.
Edit 2: I believe I have a fix for the issue.

Thanks. I am hoping it will not be too hard to isolate the culprit. I uploaded two projects. The first compiles and includes the service definition within the manifest. The second is identical to the first except that it adds the Wi-Fi extension, doesn't use it all, just adds it. When it compiles it leaves the service definition out of the manifest. Hopefully it will be not much work to find out why this happens.

On another note, this is a problem faced by all Android app developers. Android is going nuts trying to conserve battery. It ends a process, even service, after a while. My app with the notification service might run for a couple hours or the better part of a day before Android kills it and it stops notifying me. If I rerun the app, the service restarts, and notifications work again.

Is there a way to instruct Android to not kill a service or process? It seems to be getting worse as Android progresses up in versions, 8, 9, 10, 11, … I know services have been abused in the past, but just tell the user he is wasting battery and been with it.

This isn't something that App Inventor has control over. You're welcome to complain to Google, but I'd wouldn't waste the energy...

I've submitted a potential fix here

We will aim to get it into the next release.

I received a hint via email from Ulli (@Ulrich_Bien) regarding the problem and how he solved it:
https://ullisroboterseite.de/android-ai2-faq.html?topic=extension

Summary

Only the position of the source files is a bit out of date. The suggested directory

"~\appinventor-sources\appinventor\components\src\com\google\appinventor\components\runtime"

should NOT be used! Instead, it is better to set up your own source structure that corresponds to the Java package nomenclature. Like the Google sources, this structure starts in the folder

"~\appinventor-sources\appinventor\components\src".

For me it looks like this:

Directory structure

I didn't test (compile) it myself with it. But as I said, he compiled my MyFonts.java extension and the problem no longer occurs (along with his new MediaNotification).

The issue is due to how we processed the JSON content that describes the extensions. When a key wasn't found, that error terminated the extension processing early. As features have been added, we've added new keys to support those functions (e.g., services), but extensions compiled prior to the introduction of those features lack the corresponding keys since they weren't part of the build system at that time. So when you have these two extension in the project, the first (older) one doesn't have the key, the exception is thrown, and the newer extension, which does have the key, is never processed (this results in the service entry being dropped). By recompiling the extension with a newer version of the build system, the missing keys are added and so the process behaves as expected. The fix above makes it so that we don't prematurely exit the loop processing the extension information and resolves the issue even in the situation where the extension is older.

1 Like

Thank you for the detailed explanation.

Does this mean that any extensions compiled before this point will not work with extensions that contain services?

As a result, these (old) extensions would have to be recompiled to ensure that no problems arise.

Only until the next release goes out with the fix in the buildserver. There may also be an ordering effect since the extensions are processed linearly. It might be possible to have it so the newer extensions load before the older extensions so the error doesn't prevent processing the newer extension.

1 Like

Thank you, good to know.
Now I've finally got it. :wink:

meanwhile I recompiled the extension, which fixes the issue for @canalrun
the new version of the wifi extension is available for download here App Inventor Extensions: WiFi | Pura Vida Apps
thank you @ewpatton

Taifun

2 Likes