xamarin-docs
xamarin-docs copied to clipboard
Additional steps required to deploy to Android 12+
I used this documentation to incorporate Azure B2C into my app. After a week or so of running in the emulator, I decided to deploy the app to my Pixel 5 for debugging. I was greeted with an error:
INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI
...
Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present
After doing some searching I came across this doc, which explains why I encountered this issue.
To remedy the deployment error, I determined that the following changes must be made to AndroidManifest.xml and MainActivity.cs...
Updates to the Android section:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.xamarin.adb2cauthorization">
<uses-sdk android:minSdkVersion="15" />
<application android:label="ADB2CAuthorization">
<!-- Add 'android:exported="true"' to the example -->
<activity android:name="microsoft.identity.client.BrowserTabActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- example -->
<!-- <data android:scheme="msalaaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" android:host="auth" /> -->
<data android:scheme="INSERT_URI_SCHEME_HERE" android:host="auth" />
</intent-filter>
</activity>"
</application>
</manifest>
I'm not sure how to adjust the example here, but the user needs to add Export = true
inside the Activity attribute above public class MainActivity
. For example:
[Activity(Label = "MyXamarinFormsApp", Icon = "@mipmap/icon",
Exported = true, // This needs to be added to the doc
Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
...
}
I apologize for the above. It's late. Hopefully I've provided enough info to get you to update the docs. I'm sure others will encounter this as Android 12 becomes more widespread.
Thanks
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 11f5b457-d99a-06d4-d203-f9eeaa27e0d9
- Version Independent ID: b23b3a5d-b63b-dfe1-bb46-94f57c907be5
- Content: Authenticate Users with Azure Active Directory B2C - Xamarin
- Content Source: docs/xamarin-forms/data-cloud/authentication/azure-ad-b2c.md
- Product: xamarin
- Technology: xamarin-forms
- GitHub Login: @davidbritch
- Microsoft Alias: dabritch