Building Cordova Android SDK 31 target with FCM push support

Hi all,

I’m currently trying to move my build target to sdk 31, to get all things clear for upcoming playstore changes on nov 1st. I’m using The trusted source for JavaScript packages, Meteor resources and tools | Atmosphere by @paulishca . I set target SDK to 31 in mobile-settings.js

Due to some changes, the AndroidManifest.xml now requires android:exported="true" for nodes with intent-filters. As a result, building with meteor is not successful, as the above attributes are not set.

My current workaround for this is opening the prepared project in .meteor/local/... in Android Studio and edit the Manifest xml file there.

Then a second issue occurs, which is related to the new requirement that for some PendingIntend method calls a FLAG_IMMUTABLE or FLAG_MUTABLE must be set. (App crashes as soon as a notifcation in received by the device.) This comes from a file in the phonegap-plugin-push. Also this can be solved by adding the FLAG_IMMUTABLE bitmask.

I’d now like to automate the bulding process. Tried already to use edit-config options from Cordova in mobile-settings.js, but with no success (got some double entries and, hence, new errors during build). The second issue could be maybe resolved by forking that plugin and incorporating a fork into The trusted source for JavaScript packages, Meteor resources and tools | Atmosphere

Hope someone has a clue :wink:


Hi @bratelefant,

a new version of Push is due but I am not yet ready to release it. As you probably noticed, phonegap-plugin-push has been deprecated for a while and the new version of Push will be based on @havesource/cordova-plugin-push. I am just waiting for a release of Meteor 2.8 and understand the changes I need to make to accommodate it.
The same problem you have has been fixed in the @havesource/cordova-plugin-push plugin but a new version has not yet been released. If you want, I can share with you the new package and you can then try and build your project based on the indications from the new cordova plugin repo.

1 Like

Sounds great! Maybe it would be helpful for the whole community if you could publish that work in progress as a branch of your repo.

I’d need some time even to do that. A lot of things changed in the Meteor side as well. I opened the project towards having server roles, you can set up a Meteor server to only be sender of Push while the others send jobs in the queue. I am planning to add an email queue as well and enable methods for Email as well as Push since many developers think of these together. So, I don’t thing any version/branch will be published soon.

Hey @paulishca - any news on an update for Push?
We’ve been running into Android build issues with our existing project when attempting to target SDK31 due to the exported error - it seems like Meteor 2.8 requires Java11 to build properly, but your comments here make me think that we need to downgrade meteor below 2.8 until you put out an update (and stop using java11). Do you think this is the case?

Oh my word - I have been battling this for 4 days now. I use @havesource version and it took me ages to get that to install and build, BUT and think this is the crux of the problem, Cordova Android 10.x doesn’t support API 31 (Android Platform Guide - Apache Cordova) so whatever you do, it will never work. I think I have trashed my setup because I have tried every combo of JAVA 8 (which is really v1.8) and JAVA 11 but the latter fails very early on, and the former won’t build. Personally I find the whole Java/Gradle a mess and a mystery. It seems so opaque I struggled to get to the bottom of the problem, but I am in the same situation as the OP. I want to push a new version of the app to the app store, but google won’t allow it.

I think we need to ask for Cordova 11 for Android to be included in a patch release (2.8.2?)

1 Like

@leemind Meteor 2.8 is already on Cordova 10.1.2, which supports the new API level. You can learn more about it here: Unable to build/submit Android to play store - new requirements API 31 · Issue #12126 · meteor/meteor · GitHub.

The issue you are facing seems to be plugin specific, so you will either need to fork the plugin and fix the compatibility issues or maybe go another way for push notifications (like OneSignal, for example).

Many thanks - I will continue investigating

[EDIT] THANK YOU – I can’t believe I went round the houses on this, only to find one single thing was all I was missing

I had tried upgrading to JAVA 11, but it would fail very early on, complaining about the advmanager - which it didn’t with JAVA 8.

So I assumed total incompatibility – however this fixed it:

export PATH="${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${PATH}"
1 Like

Hello, about using the fixed version of the @havesource/cordova-plugin-push plugin, it is just needed to install the plugin from the github’s repo commit with the fix:

meteor add cordova:@havesource/cordova-plugin-push@

Hope this can save some time for some people :wink:

Ok, I can share with you here the configs using the new plugin but I am not ready to release a new packages due to the coming changes in Meteor.

/// activitree:push package.js

/* globals Package, Npm, Cordova */
  name: 'activitree:push',
  version: '3.0.1',
  summary: 'Push Notifications for Cordova and Web/PWA with Firebase (FCM).',
  git: ''

  'firebase-admin': '11.0.0',
  firebase: '9.9.0',
  events: '3.3.0'

  // '@havesource/cordova-plugin-push': '', // for IOS with SDK > 8.1.1
  '@havesource/cordova-plugin-push': '3.0.1' // for Android with SDK <=21.+

Package.onUse(api => {
  api.versionsFrom(['1.8', '2.7'])
  api.use(['tracker'], 'client')
  api.use(['accounts-base'], ['client', 'server'], { weak: true })

  ], ['client', 'server'])

  // API's
  api.addFiles('lib/server/pushToDevice.js', 'server')
  api.addFiles('lib/server/internalMethods.js', 'server')

  api.mainModule('lib/client/cordova.js', ['web.cordova'])
  api.mainModule('lib/client/web.js', ['web.browser'])
  api.mainModule('lib/server/pushToDB.js', ['server'])

// mobile-config.js

App.configurePlugin('@havesource/cordova-plugin-push', {
  // FCM_VERSION: '21.1.+', // off for version 3.0.1 of cordova plugin.
  SENDER_ID: '552803819837',
  IOS_FIREBASE_MESSAGING_VERSION: '9.1.0' // makes use of the new replacement of instance id for IOS. Adjust version of the plugin to pull from GIT

You would need to switch commented lines for whether you build Android (as it is se now) or you build IOS.