I have built a Godot 3.0.2.stable.official app that successfully exports and runs on both Windows and on my Android phone. I have built a pause menu with three buttons (Quit, Menu, Continue). Everything works well and I can navigate around various scenes and close my app correctly.

However, on Android the Quit button (which calls get_tree().quit()) doesn't work properly. The app seems to shut down and throws back to the phone's home/launcher screen, however if I open the list of running apps (square button) my app is still running and shows a black screen. If I select my app from the list of running apps, my app restarts.

I've played around with different placements of get_tree().quit() in my code, and the only place it works is before the first scene is displayed. After that, the app just won't close on Android.

I have tried altering the get_tree().set_auto_accept_quit() and get_tree().set_quit_on_go_back() values before quitting the app to no avail. I have even tried removing all the nodes in the SceneTree before quitting the app. Of course, everything works correctly on Windows; the issue only occurs on Android.

Have any other Android devs run into this issue?

Take note of the Godot version you are using and the specs. of your phone, then file a report here (as it sounds like a bug since the purpose of get_tree().quit is to well...quit). https://github.com/godotengine/godot

Awesome, thanks for responding.

I'm using Godot 3.0.2.stable.official. My phone is a Huawei Mate Lite (Model RNE-L21) running Android 8.0.

Let me know if you need any more details.

Have you tested any of the newer godot 3/stable builds? Between 3.0.3 and 3.0.6 the issue might already be resolved.

I just tested on the latest stable (3.0.6.stable.official.8314054) and the problem still exists.

I'll download 3.1 Alpha 2 and see if I can test it on that.

I just tested on 3.1 Alpha2 and the problem still exists.

There was an additional problem in this version; it didn't compile and I needed to make code changes to get it to run. I have an enum with a value Pause in it and there was a compile error: Member 'Pause' already exists in parent class.

Here's the line of code:

enum gameCommand { Pause, Home, Quit, Continue }

I can live with finding a different name for the value but the inability to Quit on Android is a problem.

So you have done your due diligence and confirmed that the issue exists in all versions from(essentially) 3.0.0 on-wards and as such you have a strong basis for submitting a new issue to the tracker.

One last thing to-do would be to search the tracker and see if anyone else has already submitted the issue.

edit: and there is an archived one: https://github.com/godotengine/godot/issues/7707

Apparently(as I was thinking myself as well) this is expected behavior on android.

Bugger. I had searched through the issues previously and not found this entry. Thanks for digging it up.

I'm surprised you can't quit an app on Android. Like the poster of that issue I'm new to Android and the idea that you can't quit just didn't occur to me.

Thanks again.

In android if I recall correctly(haven't owned/used one in well over a year now) there's a system settings sub-menu somewhere to disable/kill application processes but the whole OS is a mess designed to basically be constantly running everything so everything could constantly keep tabs on and collect data about the user. Google/alphabet's product is you.

It looks like the Godot Android export could support quitting the app outright if it wanted to with a System.exit(0); (see this StackOverflow answer). The question would then be whether Google would prevent an app that does this from their store.

I've been looking for something from Google saying "you must not kill the application", but so far I've only found design guidance that implies every app on Android is considered to be a service that could be called on at any time. Under such a "service" type model I can understand why apps wouldn't be closed, but I don't think games fit that model.

I've looked at how a few other games on Android deal with this. All the games I looked at provide a quit button or an "are you sure you want to quit" yes/no dialog when navigating back from their home screen. All of these apps currently have the behaviour I'm seeing; they don't actually close and restart when selected again. If the StackOverflow answer is correct, I find it interesting that they don't actually implement quit properly.

Is there a representative or body from the Google store who can be asked for definitive developer guidance here?. Personally I would like to see Godot support the ability to actually quit the app when directed by the code, but I wouldn't want to jeopardise Godot's reputation with Google (especially in light of recent events that banned Godot apps).

Yeah, I don't know either. While there is that one closed issue I pointed out earlier, it is rather old now and since you clearly have some interesting arguments here in favor of quitting it might be worth making a new issue on the subject. I'm sure the developers are willing to discuss it again should someone be bringing up some new valid points for consideration.

Do you think it would be best to raise a new issue or try to resurrect the old one?

4 years later