Ionic v3 - Android 14 - TargetSDK 34 - Crashes on Local Notification or Geolocation cordova plugin

Recently changed the android-targetSdkVersion to 34 and our app is crashing on Android 14 devices. Possibly the Local Notification plugin or Geolocation plugin, following error is seen on Android Studio Emulator debug.

Any suggestions how to go about?

java.lang.IllegalArgumentException: com.package.ionic003: Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3246)
    at android.os.Parcel.createException(Parcel.java:3226)
    at android.os.Parcel.readException(Parcel.java:3209)
    at android.os.Parcel.readException(Parcel.java:3151)
    at android.app.IActivityManager$Stub$Proxy.getIntentSenderWithFeature(IActivityManager.java:7000)
    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:765)
    at android.app.PendingIntent.getBroadcast(PendingIntent.java:748)
    at de.appplant.cordova.plugin.notification.util.LaunchUtils.getBroadcastPendingIntent(LaunchUtils.java:35)
    at de.appplant.cordova.plugin.notification.Notification.cancelScheduledAlarms(Notification.java:308)
    at de.appplant.cordova.plugin.notification.Notification.cancel(Notification.java:284)
    at de.appplant.cordova.plugin.notification.Manager.cancel(Manager.java:234)
    at de.appplant.cordova.plugin.localnotification.LocalNotification.cancel(LocalNotification.java:515)
    at de.appplant.cordova.plugin.localnotification.LocalNotification.access$600(LocalNotification.java:88)
    at de.appplant.cordova.plugin.localnotification.LocalNotification$1.run(LocalNotification.java:175)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    at java.lang.Thread.run(Thread.java:1012)

Yeah, this is a common error from packages that haven’t been updated to support the latest Android SDKs.

Looks like you are using Cordova and not Capacitor from the stacktrace? If so, have you upgraded to Cordova 13 to support SDK 34 - Android Platform Guide - Apache Cordova?

Once that is complete, you need to see if the plugins throwing the error have a newer version that supports SDK 34. It would be helpful if you shared the plugins you are using (a link to the repo or the npm package name).

Sharing my ionic info results. We understand that we are sitting on a legacy source code and we haven’t been able to get around updating the libraries. Updating to Cordova 13 requires updated Node version, which breaks many of the node module dependencies installed. :grin: I will attempt that today.

Ionic:

   Ionic CLI          : 6.18.1 (/Users/shreyasgombi/.nvm/versions/node/v10.24.1/lib/node_modules/@ionic/cli)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : 10.0.0 (cordova-lib@10.1.0)
   Cordova Platforms : android 11.0.0
   Cordova Plugins   : cordova-plugin-ionic-webview 5.0.0, (and 20 other plugins)

Utility:

   cordova-res : not installed globally
   native-run  : 2.0.1

System:

   Android SDK Tools : 26.1.1 (/usr/local/Caskroom/android-sdk/4333796)
   ios-sim           : 8.0.2
   NodeJS            : v10.24.1 (/Users/shreyasgombi/.nvm/versions/node/v10.24.1/bin/node)
   npm               : 6.14.12
   OS                : macOS Monterey
   Xcode             : Xcode 14.2 Build version 14C18

My package.json :

{
  "name": "ionic",
  "version": "1.0.0",
  "author": "Ionic Framework - Jinicommmerce",
  "homepage": "https://www.jinicommerce.com/",
  "private": true,
  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "5.0.3",
    "@angular/compiler": "5.0.3",
    "@angular/compiler-cli": "5.0.3",
    "@angular/core": "5.0.3",
    "@angular/forms": "5.0.3",
    "@angular/http": "5.0.3",
    "@angular/platform-browser": "5.0.3",
    "@angular/platform-browser-dynamic": "5.0.3",
    "@ionic-native/app-version": "^4.7.0",
    "@ionic-native/barcode-scanner": "^4.12.2",
    "@ionic-native/bluetooth-serial": "^4.20.0",
    "@ionic-native/camera": "^4.20.0",
    "@ionic-native/contacts": "^4.6.0",
    "@ionic-native/core": "^4.20.0",
    "@ionic-native/device": "^4.12.0",
    "@ionic-native/file": "^4.6.0",
    "@ionic-native/geolocation": "^4.20.0",
    "@ionic-native/keyboard": "^4.20.0",
    "@ionic-native/launch-navigator": "^4.18.0",
    "@ionic-native/local-notifications": "^4.12.0",
    "@ionic-native/location-accuracy": "^4.20.0",
    "@ionic-native/media-capture": "^4.6.0",
    "@ionic-native/network": "^4.20.0",
    "@ionic-native/social-sharing": "^4.20.0",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/sqlite": "^4.7.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/storage": "2.1.3",
    "@types/node": "^12.7.7",
    "angularx-qrcode": "^1.6.4",
    "cordova-pdf-generator": "^2.0.8",
    "cordova-plugin-actionsheet": "^2.3.3",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-bluetooth-serial": "0.4.7",
    "cordova-plugin-console": "^1.1.0",
    "cordova-plugin-contacts": "^3.0.1",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-dialogs": "^2.0.1",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-media-capture": "^3.0.2",
    "cordova-plugin-network-information": "2.0.1",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-sqlite-storage": "^6.0.0",
    "crypto-js": "^4.0.0",
    "datejs": "^1.0.0-rc3",
    "esc-pos-encoder-ionic": "^1.1.3",
    "highcharts": "^6.2.0",
    "ionic-angular": "3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionic2-rating": "^1.2.2",
    "ionic2-super-tabs": "^4.2.2",
    "ionicons": "3.0.0",
    "moment": "^2.29.4",
    "ng-lottie": "^0.3.2",
    "ng-socket-io": "^0.2.4",
    "node-js-marker-clusterer": "^1.0.0",
    "rxjs": "^5.5.12",
    "sw-toolbox": "3.6.0",
    "uk.co.workingedge.phonegap.plugin.launchnavigator": "^4.2.2",
    "zone.js": "0.8.18"
  },
  "description": "An Ionic project developed and maintained inhouse by Team Jinicommerce",
  "cordova": {
    "plugins": {
      "ionic-plugin-keyboard": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-contacts": {},
      "cordova-plugin-media-capture": {},
      "cordova-plugin-device": {},
      "cordova-plugin-app-version": {},
      "uk.co.workingedge.phonegap.plugin.launchnavigator": {
        "OKHTTP_VERSION": "3.+",
        "LOCATION_USAGE_DESCRIPTION": "This app requires access to your location for navigation purposes"
      },
      "cordova-pdf-generator": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-bluetooth-serial": {},
      "cordova-plugin-ionic-webview": {},
      "phonegap-plugin-barcodescanner": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-local-notification-12": {
        "ANDROID_SUPPORT_V4_VERSION": "26.+",
        "ANDROIDX_VERSION": "1.2.0",
        "ANDROIDX_APPCOMPAT_VERSION": "1.3.1"
      },
      "cordova-plugin-geolocation": {
        "GPS_REQUIRED": "true"
      },
      "cordova-plugin-request-location-accuracy": {
        "PLAY_SERVICES_LOCATION_VERSION": "16.+"
      },
      "cordova-plugin-x-socialsharing": {
        "PHOTO_LIBRARY_ADD_USAGE_DESCRIPTION": "This app requires photo library access to function properly.",
        "PHOTO_LIBRARY_USAGE_DESCRIPTION": "This app requires photo library access to function properly."
      },
      "onesignal-cordova-plugin": {},
      "cordova-sqlite-storage": {},
      "cordova-plugin-camera": {
        "ANDROIDX_CORE_VERSION": "1.6.+"
      }
    },
    "platforms": [
      "ios",
      "android"
    ]
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.2.4",
    "cordova-android": "^11.0.0",
    "cordova-ios": "^6.3.0",
    "cordova-plugin-badge-fix": "^0.8.10",
    "cordova-plugin-camera": "git+https://github.com/jalios/cordova-plugin-camera.git",
    "cordova-plugin-geolocation": "^4.1.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-local-notification-12": "^0.1.4",
    "cordova-plugin-request-location-accuracy": "^2.3.0",
    "cordova-plugin-x-socialsharing": "^6.0.4",
    "es6-promise-plugin": "^4.2.2",
    "onesignal-cordova-plugin": "^3.3.1",
    "phonegap-plugin-barcodescanner": "^8.1.0"
  }
}

Sadly I think you are going to have to put the work into upgrading. You’ve got a ton a plugins that is probably gonna take some work too.

On a related note, @ionic-native was deprecated in 2021 and changed to awesome-cordova-plugins. See A New Chapter for @ionic-native - Ionic Blog.

Looking at your local notification plugin, it appears you are using cordova-plugin-local-notification-12 which appears to be a fork of cordova-plugin-local-notifications. The latter is the one mentioned in the @ionic-native/local-notifications documentation and has more recent commits.

1 Like