question

WongWeiLoon-2912 avatar image
0 Votes"
WongWeiLoon-2912 asked LeonLu-MSFT edited

Xamarin: Issue when TargetSdkVersion set to API 31 in manifest

By refer to Xamarin.Android 12.0 Release Notes, I set TargetFramework to Android 12 and I able to deploy project without any problem. However, I encountered following error when I set android:targetSdkVersion to API 31 in android manifest.

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

This happens only when android:targetSdkVersion set to 31 and I already added android:exported="true" to MainActivity class and classes that use intent filters. Could anyone advice me how to resolve this?







dotnet-xamarin
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

com.urbanairship.accengage.PackageUpdatedReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]

Based on this error, you should add android:exported to PackageUpdatedReceiver not add it to MainActivity. If PackageUpdatedReceiver is a broadcast receiver, you can add android:exported property like following code.

[BroadcastReceiver(Enabled = true, Exported = true)]
    public class PackageUpdatedReceiver : BroadcastReceiver
    {
        public override void OnReceive(Context context, Intent intent)
        {
            Toast.MakeText(context, "Received intent!", ToastLength.Short).Show();
        }
    }

I donot know if you used statically-registered broadcast receiver or include intent-filters. You can refer this thread about setting true or false for Exported

For a statically-registered broadcast receiver, the Enabled properly must be set to true, otherwise Android will not be able to create an instance of the receiver.

For dynamic-registered broadcast receiver. The Exported property controls whether the broadcast receiver can receive messages from outside the application. If there is at least one intent-filter for the broadcast receiver the Exported property is true. If there are no intent-filters associated with the broadcast receiver, this value could be false.



0 Votes 0 ·

Basically we use only intent-filters and no BroadcastReceiver in our project. And, we already added android:exported="true" to the classes.
It's strange that this issue happened only in physical devices/emulator with android 12

0 Votes 0 ·
LeonLu-MSFT avatar image LeonLu-MSFT WongWeiLoon-2912 ·

Can you share a demo that could reproduce this issue?

0 Votes 0 ·
Show more comments

1 Answer

LeonLu-MSFT avatar image
0 Votes"
LeonLu-MSFT answered LeonLu-MSFT edited

Hello,​


If you install other nugget packages, please update them to the latest.

Best Regards,

Leon Lu



If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Finally it works now after I update airship, firebase and GooglePlayServices NuGet packages to latest version.

0 Votes 0 ·
LeonLu-MSFT avatar image LeonLu-MSFT WongWeiLoon-2912 ·

Thanks for your update, I convert my comment to answer, it will help others who have similar issue.

0 Votes 0 ·