Skip to content

[🐛] App Closes On Back Button in Nested Stack Page with BannerAd Loaded (Android) #813

@s1tony

Description

@s1tony

What happened?

In my React Native App, I am utilizing React Navigation with a nested stack navigator. On the initial page in the nested navigator, I am displaying a Banner Ad. When I press the Back button, the App closes unexpectedly, as the App should navigate to the parent navigator.

I confirmed the issue is somehow related to the Banner Ad by commenting out the Banner Ad, in which case pressing the Back button navigates back to the parent, as expected.

It seems as though the Banner Ad needs to be unloaded before navigating back, but I do not see a good way of doing this.

If I am overlooking something , I apologize, This seems as though it should be a pretty standard situation, but do not see any other posts about it.

Platforms

Android, but have not tested behavior on iOS

React Native Info

System:
  OS: Windows 11 10.0.26100
  CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz
  Memory: 34.29 GB / 63.81 GB
Binaries:
  Node:
    version: 22.11.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.22
    path: C:\Program Files\nodejs\yarn.CMD
  npm:
    version: 11.6.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-212.5712.43.2112.8609683
  Visual Studio:
    - 17.14.36518.9 (Visual Studio Community 2022)
Languages:
  Java: javac 17
  Ruby:
    version: 3.2.2
    path: C:\Ruby32-x64\bin\ruby.EXE
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: 18.0.0
  react:
    installed: 19.0.0
    wanted: "19.0"
  react-native:
    installed: 0.79.6
    wanted: ^0.79.6
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Are your using Typescript?

  • My project is using Typescript

package.json

{
  "name": "collections",
  "version": "2.0.0",
  "private": true,
  "scripts": {
    "android": "expo run:android",
    "android-user": "react-native run-android --mode=userdebug --appIdSuffix 'user'",
    "android-coin": "react-native run-android --mode=coindebug --appIdSuffix 'coin'",
    "android-user-release": "react-native run-android --mode=userrelease --appIdSuffix 'user'",
    "android-coin-release": "react-native run-android --mode=coinrelease --appIdSuffix 'coin'",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@huggingface/inference": "^3.5.1",
    "@journeyapps/react-native-quick-sqlite": "^2.4.7",
    "@powersync/react-native": "^1.23.2",
    "@react-native-async-storage/async-storage": "^1.24.0",
    "@react-native-community/datetimepicker": "^8.2.0",
    "@react-native-firebase/app": "^23.3.1",
    "@react-native-firebase/auth": "^23.3.1",
    "@react-navigation/native": "^7.1.17",
    "@react-navigation/native-stack": "^7.3.24",
    "@react-navigation/stack": "^7.4.5",
    "@rneui/base": "^4.0.0-rc.7",
    "@rneui/themed": "^4.0.0-rc.8",
    "axios": "^1.7.9",
    "bson": "^6.10.2",
    "date-fns": "^4.1.0",
    "minisearch": "^7.1.1",
    "openai": "^4.86.2",
    "react": "19.0",
    "react-native": "^0.79.6",
    "react-native-bootsplash": "^6.3.2",
    "react-native-config": "^1.5.3",
    "react-native-gesture-handler": "^2.28.0",
    "react-native-get-random-values": "^1.11.0",
    "react-native-google-mobile-ads": "^15.8.3",
    "react-native-iap": "^14.4.12",
    "react-native-image-crop-picker": "^0.41.6",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-keychain": "^9.2.2",
    "react-native-logs": "^5.3.0",
    "react-native-markdown-display": "^7.0.2",
    "react-native-nitro-modules": "^0.29.6",
    "react-native-permissions": "^5.2.5",
    "react-native-reanimated": "^3.18.0",
    "react-native-safe-area-context": "^5.6.1",
    "react-native-screens": "^4.13.1",
    "react-native-select-dropdown": "^4.0.1",
    "react-native-vector-icons": "^10.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@babel/preset-env": "^7.25.3",
    "@babel/runtime": "^7.25.0",
    "@react-native-community/cli": "18.0.0",
    "@react-native-community/cli-platform-android": "18.0.0",
    "@react-native-community/cli-platform-ios": "18.0.0",
    "@react-native/babel-preset": "0.79.6",
    "@react-native/eslint-config": "0.79.6",
    "@react-native/metro-config": "0.79.6",
    "@react-native/typescript-config": "0.79.6",
    "@types/jest": "^29.5.13",
    "@types/react": "^19.0.0",
    "@types/react-test-renderer": "^19.0.0",
    "@types/ungap__structured-clone": "^1.2.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "19.0.0",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}

app.json

{
  "name": "Collections",
  "displayName": "Collections",
  "react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-7079219138048644~8977765950",
    "ios_app_id": "ca-app-pub-7079219138048644~4242278166",
    "user_tracking_usage_description": "This identifier will be used to deliver personalized ads to you.",
    "sk_ad_network_items": [
      "cstr6suwn9.skadnetwork",
      "4fzdc2evr5.skadnetwork",
      "2fnua5tdw4.skadnetwork",
      "ydx93a7ass.skadnetwork",
      "p78axxw29g.skadnetwork",
      "v72qych5uu.skadnetwork",
      "ludvb6z3bs.skadnetwork",
      "cp8zw746q7.skadnetwork",
      "3sh42y64q3.skadnetwork",
      "c6k4g5qg8m.skadnetwork",
      "s39g8k73mm.skadnetwork",
      "3qy4746246.skadnetwork",
      "hs6bdukanm.skadnetwork",
      "mlmmfzh3r3.skadnetwork",
      "v4nxqhlyqp.skadnetwork",
      "wzmmz9fp6w.skadnetwork",
      "su67r6k2v3.skadnetwork",
      "yclnxrl5pm.skadnetwork",
      "7ug5zh24hu.skadnetwork",
      "gta9lk7p23.skadnetwork",
      "vutu7akeur.skadnetwork",
      "y5ghdn5j9k.skadnetwork",
      "v9wttpbfk9.skadnetwork",
      "n38lu8286q.skadnetwork",
      "47vhws6wlr.skadnetwork",
      "kbd757ywx3.skadnetwork",
      "9t245vhmpl.skadnetwork",
      "a2p9lx4jpn.skadnetwork",
      "22mmun2rn5.skadnetwork",
      "4468km3ulz.skadnetwork",
      "2u9pt9hc89.skadnetwork",
      "8s468mfl3y.skadnetwork",
      "ppxm28t8ap.skadnetwork",
      "uw77j35x4d.skadnetwork",
      "pwa73g5rt2.skadnetwork",
      "578prtvx9j.skadnetwork",
      "4dzt52r2t5.skadnetwork",
      "tl55sbb4fm.skadnetwork",
      "e5fvkxwrpn.skadnetwork",
      "8c4e2ghe7u.skadnetwork",
      "3rd42ekr43.skadnetwork",
      "3qcr597p9d.skadnetwork"
    ]
  }
}

ios/Podfile

android/build.gradle

android/app/build.gradle

android/settings.gradle

AndroidManifest.xml

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions