Android Question Request to fix bug in B4A for APK submission to Play Store, targeting SDK 34

abilio486software

Active Member
Licensed User
We are using ‘Receivers’ and when we register them, in a version that points to SDK 34, an error occurs saying that it is not EXPORTED.

If we change the target to Android 33, it works.

But Google won't let you submit APKs if they're not for Android SDK 34.

We urgently need the RegisterReceiver to be able to allow EXPORTED or NOT EXPORTED, so that we can update our app in the Play Store.

Urgent request!

Thanks
Abilio
 

josejad

Expert
Licensed User
Longtime User
Upvote 0

abilio486software

Active Member
Licensed User
Related

I'd seen that one, but thank you very much.
B4X:
Broadcast.registerReceiver("......")
It only works if it's targeted to SDK 33
It must be solved because Play Store only accepts APKs targeted for SDK 34.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
something doesn't sound right here. you can set your receivers to be exported or not
in your manifest. when you refer to "registering" your receivers, this sounds like you
are using dynamic receivers, not manifest-declared receivers. is that the case? what
does your manifest look like? if you're using context-declared receivers, you set a flag
to export at time of registration.
 
Upvote 0

abilio486software

Active Member
Licensed User
something doesn't sound right here. you can set your receivers to be exported or not
in your manifest. when you refer to "registering" your receivers, this sounds like you
are using dynamic receivers, not manifest-declared receivers. is that the case? what
does your manifest look like? if you're using context-declared receivers, you set a flag
to export at time of registration.
Many thanks for your help.

We are using this code:
B4X:
'Called when an intent is received.
'Do not assume that anything else, including the starter service, has run before this method.
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
    If FirstTime=True Then
       
        Broadcast.Initialize("Taxitronic")
       
        'Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
        Broadcast.addAction("Taxitronic.LastTripData.Response")
        Broadcast.addAction("Taxitronic.InTripData.Response")
        Broadcast.addAction("Taxitronic.InStopData.Response")
       
        Broadcast.SetPriority(2147483647)
       
        Broadcast.registerReceiver("Taxitronic.LastTripData.Response") 'here you can add the main action (intent)
        Broadcast.registerReceiver("Taxitronic.InTripData.Response") 'here you can add the main action (intent)
        Broadcast.registerReceiver("Taxitronic.InStopData.Response") 'here you can add the main action (intent)
       
    End If
End Sub

And our manifest have:

B4X:
AddApplicationText(
                   
                    <receiver android:name="taxitronic"
                              android:exported="true" >
                              <intent-filter>
                                     <action android:name="Taxitronic.LastTripData.Response"/>
                                     <action android:name="Taxitronic.InTripData.Response"/>
                                     <action android:name="Taxitronic.InStopData.Response"/>

                              </intent-filter>
                    </receiver>
                )
               
               
AddReceiverText(taxitronic, <intent-filter> <action android:name="Taxitronic.LastTripData.Response" exported="true"/></intent-filter>)
AddReceiverText(taxitronic, <intent-filter> <action android:name="Taxitronic.InTripData.Response"  exported="true"/></intent-filter>)
AddReceiverText(taxitronic, <intent-filter> <action android:name="Taxitronic.InStopData.Response"  exported="true"/></intent-filter>)

With SDK targeted to 33 works perfectly.

If we target to SDK 34, does not work, fires this exeption:

One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
 
Last edited:
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
i don't know how you managed to do this, but my guess is your so-called ".broadcast" receiver didn't make it to the manifest:

XML:
<receiver android:name="taxitronic" android:exported="true">
<intent-filter>
<action android:name="Taxitronic.LastTripData.Response"/>
<action android:name="Taxitronic.InTripData.Response"/>
<action android:name="Taxitronic.InStopData.Response"/>
</intent-filter>
</receiver>
<receiver android:name="broadcast" android:exported="true">
<intent-filter>
<action android:name="Taxitronic.LastTripData.Response"/>
<action android:name="Taxitronic.InTripData.Response"/>
<action android:name="Taxitronic.InStopData.Response"/>
</intent-filter>
</receiver>


<receiver android:name=".taxitronic" android:exported="true">
<intent-filter>
<action android:name="Taxitronic.LastTripData.Response" exported="true"/>
</intent-filter>
<intent-filter>
<action android:name="Taxitronic.InTripData.Response" exported="true"/>
</intent-filter>
<intent-filter>
<action android:name="Taxitronic.InStopData.Response" exported="true"/>
</intent-filter>
</receiver>

that library you're using is very old. it looks like it isn't going to work with sdk34. it's not a b4a bug.
the library's registerReceiver() method does not include the additional parameter for setting the export flag (required for sdk34).
but you should still be able to set the receiver's attribute with the manifest editor with SetReceiverAttribute(myReceiver, "android:exported", true) or false.
more troubling is why the .broadcast receiver doesn't appear in the manifest. i think that's why you see the exception.

by the way, did you actually receive approval from google for your specialuse foreground service? how difficult was that?
 
Last edited:
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
you know, you don't need to register a receiver in code. just declare it in the manifest; it's automatically "registered". you can set your export flag.
 
Upvote 0

abilio486software

Active Member
Licensed User
1. This is not a bug in B4A.
2. You should have posted the full error message.
3. You haven't provided enough information in the first post. Where does "RegisterReceiver" come from?

For further assistance please start a new thread.

Erel asked me for the manifest and I sent it, then I get this reply from you...

Unfortunately, Erel's laconic response didn't help at all.

The error wasn't with B4A, it was with the BroadcastReceiver library (I don't know who made it).

BroadcastReceiver can't register, you have to work around it, as Erel pointed out on June 17, 2024:

https://www.b4x.com/android/forum/t...-receiver-unable-to-start.162121/#post-994503

Anyway, it's been resolved but Erel could have helped...
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
The error wasn't with B4A, it was with the BroadcastReceiver library (I don't know who made it).
Always try to use the forum search.
I found the library was created by XverhelstX in 2011.
 
Upvote 0

abilio486software

Active Member
Licensed User
Is this what you need?

Yes, it's already solved with that solution!

Many thanks ?
 
Upvote 0
Top