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.

bug: Android crashes when calling exitApp();

See original GitHub issue

Bug Report

Capacitor Version

šŸ’Š   Capacitor Doctor  šŸ’Š 

Latest Dependencies:

  @capacitor/cli: 2.4.0
  @capacitor/core: 2.4.0
  @capacitor/android: 2.4.0
  @capacitor/electron: 2.4.0
  @capacitor/ios: 2.4.0

Installed Dependencies:

  @capacitor/ios not installed
  @capacitor/cli 2.4.0
  @capacitor/core 2.4.0
  @capacitor/android 2.4.0
  @capacitor/electron not installed

[success] Android looking great! šŸ‘Œ

Platform(s)

Android

Current Behavior

I wanted to implement the ā€˜close app on native back buttonā€™ feature. When I call the exitApp() method the app closes and crashes. The app is still in the list of apps running in the background, but when the user re-opens the app the splash screen is shown and the app boots freshly.

Debugger output: 9592f21b88cc660262b786244638290855042c5d

Expected Behavior

Iā€™d expect the app to not crash. It should pause in the background and resume when re-opened. (Just like it was with Cordova in the past).

Code Reproduction

    if (!this.platform.is('android')) {
      return;
    }

    this.platform.backButton.subscribeWithPriority(1, () => {
      if (!this.routerOutlet.canGoBack()) {
        App.exitApp();
      }
    });

Iā€™ve also created a minimal demo app, which reproduces the issue: https://github.com/burningparrot/ionic-exit-app-crash-demo

Reproduction steps:

1.) clone the repo above 2.) ionic cap open android 3.) run the app in debug mode on a physical device 4.) push the deviceā€™s native back button to close the app 5.) Carefully observe the debugger output on android studio 6.) re-open the app from the background

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jcesarmobilecommented, Oct 20, 2020

Iā€™ve tested on 3 different devices and I canā€™t reproduce the crash, and by the message it looks like a chrome bug, not a Capacitor bug.

App.exitApp(); kills the app activity, it does exactly the same as Cordovaā€™s navigator.app.exitApp();. After calling any of them the appā€™s activity is killed, and if you open it again, it will reload the whole app, not resume it. It remains in ā€œrecent itemsā€, but that doesnā€™t mean itā€™s backgrounded, recent items shows any app that was recently closed. If you donā€™t want the app to appear when it has been closed you can add android:autoRemoveFromRecents="true" to the activity tag in AndroidManifest.xml.

0reactions
ionitron-bot[bot]commented, Nov 11, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do my apps keep crashing on Android, How to fix it
The easiest way to fix an app that keeps crashing on your Android smartphone is to simply force stop it and open it...
Read more >
Why does my React Native Android app crash when closed or ...
I have tried BackHandler.exitApp() but that also exits the app with a crash. I am using React Navigation and I can see the...
Read more >
Crashes - Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >
Crash on exit via back button on Huawei Mate 20 Pro
On my huawei mate 20 Pro, any Qt application crashes when I try to exit with the android back button. This wouldn't be...
Read more >
Application is crashing on Android - Ionic Forum
firstEventAppV1 W/PluginManager: THREAD WARNING: exec() call to CoreAndroid.exitApp blocked the main thread for 30ms. Plugin should useĀ ...
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