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 FCMService.java 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:

1 Like

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?)

@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