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: Ionic 4 back button restart app (DOM) when you are in root [Cordova/App]

See original GitHub issue

Bug Report

Ionic version:

[x] 4.6.2 | 4.1

Current behavior:

the android back button reboots doom when it is in the last component

Gif Expected behavior: Close app

Steps to reproduce:

  • Run ionic start “new project”
  • Choose tab app
  • run in android platform

example image

Other information:

I noticed the error when I was developing my app and I stopped at the root page and press the button back. Apart from this, it is not detecting the backbutton subscribe Ionic info:

Ionic:

   Ionic CLI                     : 5.0.1 (/usr/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.6.2
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 24 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.2.7

System:

   Android SDK Tools : 26.1.1 (/home/juan/Android/Sdk)
   NodeJS            : v11.15.0 (/usr/bin/node)
   npm               : 6.10.0
   OS                : Linux 4.19

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
tntwistcommented, Jul 17, 2019

Hi @SidiBecker,

here is a little guide for you:

  1. clone the ionic repo/your forked repo
  • open your favorite command line application
  • run git clone https://github.com/ionic-team/ionic or git clone url-to-your-fork and change the directory to the cloned repo (cd ionic)
  • make sure to checkout the tagged commit for the current released version with git checkout v4.6.2
  1. install node modules
  • run npm install in the base directory of the cloned repo
  • change the directory to the core directory and run npm install again
  1. make the appropriate changes to the app.tsx file located under core/src/components/app (see https://github.com/ionic-team/ionic/pull/18794/files, the ionic devs already merged the pr and did some cleanings)
  2. build the core pagacke of ionic
  • make sure you are in the core directory of the ionic repo with your command line application
  • run npm run-script build
  • wait for build to complete. a dist folder should be created inside the core folder of the repo.
  1. copy the dist folder to the node_modules folder of your app project
  • locate the node_modules folder in the project directory of your app and open it. delete the dist folder inside @ionic/core.
  • copy the dist folder created by the build script in step 4 to the @ionic/core folder inside the node_modules of your app
  1. Finish 😃. With the next build of your app the hardware back button should work again.

Caution: Modifying your node_modules is a pretty dirty way and could result in other bugs/unexpected behaviors. I recommend you wait for the next offical release and just update your package.json reference of ionic.

1reaction
TejasBhitlecommented, Jul 20, 2019

Thank you so much @tntwist

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: Ionic 4 back button restart app (DOM) when you ... - GitHub
Hi there. The hardware back button was not imported in the app.tsx after the minify with arrow functions. I`m providing a pull request....
Read more >
bug in Ionic 4 back button restart app (DOM) when you are in ...
When user clicks over hardware back button of Android app built with Ionic 4. It just restart the without executing subscribed code. self....
Read more >
Hardware Back Button for Capacitor & Cordova on Android ...
When running in a Capacitor or Cordova application, Ionic Framework will emit an ionBackButton event when a user presses the hardware back button....
Read more >
How to Build Your First Ionic 6 App with API Calls
The service will take care of handling the API calls and simply return the data to our view later! Assets. This folder contains...
Read more >
Mobile App Development with Ionic, Revised Edition
Cordova. 6. Prerequisites for Ionic Application Development ... The Ionic CLI has another very powerful feature that allows you to reload the app....
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