xamarin .NET MAUI中的Azure B2C

gt0wga4j  于 2022-12-25  发布在  .NET
关注(0)|答案(1)|浏览(163)
<application android:label="ADB2CAuthorization">
        <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" />
                <data android:scheme="msal59206468-8451-4503-b081-79b09b295d1a" android:host="auth" />
            </intent-filter>
        </activity>
    </application>

将上述粘贴代码添加到AndroidManifest.xml文件会导致应用程序产生以下错误。

Error XA0134: The application does not have the 'android:debuggable' attribute set in the AndroidManifest.xml.
This is required in order for Fast Deployment to work. This is normally enabled by default by 
the Xamarin.Android build system for Debug builds. Please check that you to not have this attribute
set on the 'application' element in your 'AndroidManifest.xml'.
If you have a class that derives from 'Android.App.Application' and are using the '[Application]' make sure the 
'Debuggable' property is not set at all as it will override the value for debug builds.         0

添加可调试属性会使应用程序部署失败。
任何人谁成功地集成到他/她的MAUI应用程序的Android请帮助

anhgbhbe

anhgbhbe1#

安卓清单.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
        <activity android:name="microsoft.identity.client.BrowserTabActivity" android:configChanges="orientation|screenSize" 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" />
                <data android:scheme="msal59206468-8451-4503-b081-79b09b295d1a" android:host="auth" />
            </intent-filter>
        </activity>
        <activity android:name="MauiAppBasic.Platforms.Android.Resources.MsalActivity" android:configChanges="orientation|screenSize" 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" />
                <data android:scheme="msal59206468-8451-4503-b081-79b09b295d1a" android:host="auth" />
            </intent-filter>
        </activity>
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

然后在Android项目MsalActivity.cs内创建一个C#类

using Android.App;
using Android.Content;
using Microsoft.Identity.Client;

namespace MedbaseApplication.Platforms.Android
{
    [Activity(Exported = true)]
    [IntentFilter(new[] { Intent.ActionView },
        Categories = new[] { Intent.CategoryBrowsable, Intent.CategoryDefault },
        DataHost = "auth",
        DataScheme = "msalxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx")]
    public class MsalActivity : BrowserTabActivity
    {
    }
}

有关更多信息,请访问链接https://devblogs.microsoft.com/dotnet/authentication-in-dotnet-maui-apps-msal/,此Xamarin指南可能也会有所帮助https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-net-xamarin-android-considerations

相关问题