OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
104 stars 50 forks source link

Build fails when targeting Android 12 - Explicitly declare android:exported #248

Closed nico6ka closed 2 years ago

nico6ka commented 2 years ago

Description:

I'm trying to test targeting Android 12. The build is failing because of not declaring the android:exported in the manifest. When I checked the merged manifest file, I found that OneSignal doesn't declare android:exported.

https://developer.android.com/about/versions/12/behavior-changes-12#exported

This is the error:

Manifest merger failed with multiple errors, see logs Error: Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

Issue is fixed in OneSignal Android SDK 4.4.1. #1349 but if I am not wrong, Xamarin SDK use version 3.10.6

jkasten2 commented 2 years ago

@abramov7 The 3.0.0-beta1 SDK is now live with these changes. Check out the OneSignal Xamarin SDK Version 4 - Beta now available!#262 thread for more details.

dealdiane commented 2 years ago

Even with 4.0.0-beta5, this still doesn't work which means that targeting Android 12 is impossible.

ADB0010: Mono.AndroidTools.InstallFailedException: Unexpected install output: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl2119947732.tmp/base.apk (at Binary XML file line #65): com.onesignal.GcmBroadcastReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]

EDIT: Fixed by replacing GcmBroadcastReceiver with FCMBroadcastReceiver in AndroidManifest.xml. There's been no mention of this anywhere. Perhaps add that in the migration step?

jkasten2 commented 2 years ago

@dealdiane Thanks for pointing that out, GcmBroadcastReceiver can be completely removed actually. No need to have FCMBroadcastReceiver in your AndroidManifest.xml, the SDK now automatically handles this at build time.

We will update the migration guide to add this removal step.

jkasten2 commented 2 years ago

We added Step 6 - Android - AndroidManifest.xml Changes to account for this.

The OneSignal-Xamarin-SDK 4.0.0 release is now live and out of beta!

dealdiane commented 2 years ago

@jkasten2 Thanks. I can't see that anything about updating AndroidManifest.xml that you just just added though.

jkasten2 commented 2 years ago

@dealdiane Thanks for pointing that out, not sure what happened but added back the section again.