API_34 and above requires to use either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED flags
Location - Create and monitor Geofence sample crashes on API level 34 and above devices.
As per the registerReceiver documentation says:
For apps targeting Build.VERSION_CODES.UPSIDE_DOWN_CAKE, either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED must be specified if the receiver is not being registered for system broadcasts or a SecurityException will be thrown. See registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter, int) to register a receiver with flags.
It is necessary to use one of these flags when targeting API_34 and above.
Evidence:
https://github.com/android/platform-samples/assets/94565457/9b708fda-5a5a-48a2-a086-4c225a01e122
Exception:
java.lang.SecurityException: com.example.platform.app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts at android.os.Parcel.createExceptionOrNull(Parcel.java:3057) at android.os.Parcel.createException(Parcel.java:3041) at android.os.Parcel.readException(Parcel.java:3024) at android.os.Parcel.readException(Parcel.java:2966) at
There is an additional error when registering a geofence which is again related to API levels when passing a PendingIntent flag to getBroadcast() function located in the same screen above exception thrown. I can create another PR for that.