Problem with back button in the apk

I needed to set the page that my ionic app should go back to when clicking on the back button, so I had to override the backButtonClick function like this :

this.navBar.backButtonClick = (e: UIEvent) => {



This is working when running the app in the browser by using this command

ionic serve --lab

and it’s working when building the app and simulating it on an android device by using this command :

android cordova run android

But it’s not working when generatting the apk and installing it on the android device, and the back button is still taking me to the previous page.

I couldn’t know what the problem is, could someone help ?
Is there any way to debug the apk when installed and run on the android device ?

Thanks in advance.