Android Question Firebase Cloud Messaging & Manifest - IMPORTANT!

Marcos Alves

Well-Known Member
Licensed User
Longtime User
In SDK 28 (Android 9) a very important permission MUST TO BE ADDED to the Manifest. Up to SDK 27 there is no impact if you don't use this permission BUT starting at SDK 28 the Firebase Cloud Messaging WILL NOT WORK and will raise an error.
To avoid this error it's only required to add the follow permission to manifest using B4A manifest editor:

B4X:
AddPermission(android.permission.FOREGROUND_SERVICE)

More details can be read at Android Migration Notes: https://developer.android.com/about/versions/pie/android-9.0-migration#tya

As suggested by @JohnCody , You will get the follow error on SDK 28 and Android 9 if you don't use the permission in manifest (when the app in in ForeGround and a Firebase message arrives)

java.lang.RuntimeException: Unable to start service com.comten.nexphone.firebasemessaging@f3fffa5 with Intent { cmp=com.comten.nexphone/.firebasemessaging (has extras) }: java.lang.RuntimeException: java.lang.SecurityException: Permission Denial: startForeground from pid=12936, uid=10085 requires android.permission.FOREGROUND_SERVICE
 
Last edited:

JohnC

Expert
Licensed User
Longtime User
It would be helpful to include the text of the error message you mentioned in your post - this way if someone else gets that error, they can find your post when they do a keyword search in this forum using the error text as the query.
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
It would be helpful to include the text of the error message you mentioned in your post - this way if someone else gets that error, they can find your post when they do a keyword search in this forum using the error text as the query.
I'm doing this ...
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
I moved this thread to the questions forum as it is confusing.

The error happened because you set targetSdkVersion to 28. The recommended value for now is 26. Once you set it to the recommended value it will work.
Hello @Erel ,

ok, I know that if we use SDK 26 it will work, BUT will work also with SDK 28 and this line on manifest. By the way, is there any other known issue or limitation with SDK 28 and B4A? I'm questioning because due the requirement to change and test the apks to 64 bits (because the native libraries those we use), we have a limited time to identify and eventually fix any error (that's why the sooner we start to use SDK 28, more time we will have to develop new native libs when required and fix the errors)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
No need to wait for any "fix" or somewhat!

Check all libraries you are using. NOW.

If they do use native .so Files: Check if there is a 64bit .so file too.
- If yes, you are save.
- If not then you need to get an Update of this lib which contains a 64 bit .so file too.

If they do not use any native .so file then
- you are save; it is 64bit ready already.
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
No need to wait for any "fix" or somewhat!

Check all libraries you are using. NOW.

If they do use native .so Files: Check if there is a 64bit .so file too.
- If yes, you are save.
- If not then you need to get an Update of this lib which contains a 64 bit .so file too.

If they do not use any native .so file then
- you are save; it is 64bit ready already.
Yes @DonManfred , we use some .so libs for:

- SIP and telephony
- Compress (ffmpeg)
- Video (VLC Wrapper)

are some of them... so we are already testing on Android 9 and SDK 28...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. The terms are important. There is no such thing as SDK 28.
2. There is no relation between the 64 bit requirement (which almost all apps meet) and setting targetSdkVersion to 28.
By the way, is there any other known issue or limitation with SDK 28 and B4A?
The issues or limitations are not related to B4A. There are new requirements that you should meet. As I wrote they are quite simple to meet and everything will be explained. You will have more than enough time to meet these requirements.
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
1. The terms are important. There is no such thing as SDK 28.
2. There is no relation between the 64 bit requirement (which almost all apps meet) and setting targetSdkVersion to 28.

The issues or limitations are not related to B4A. There are new requirements that you should meet. As I wrote they are quite simple to meet and everything will be explained. You will have more than enough time to meet these requirements.
Hello @Erel . I understand that the limitations and changes are related to the Google decision which is implementing all the new security restrictions and upgrade requirements in the new Android version (V9 - Pie). The 64 bit requirement has a "side" relation with sdk 28... see:

1. Starting at November-2019, all apps must to be 64 bits compliant
2. Also the new apps will need to use SDK 28... no SDK downgrade will be allowed

Some of .so native libs recompiled to support 64 bits could eventually don't work with SDK 28... and that's why we are testing together SDK 28 AND 64 bits libs... about the time requirement, due its complexity I estimated that for some libs (SIP lib based on pjsip for example), we could spend 60-90 days to get a new stable version and more 30 days in beta testing with users... that's why we are worried about time.
 
Upvote 0
Top