错误 - 意图过滤器:缺少 BrowserTabActivity。使用 AzureAD MSAL Lilbary 时

Por*_*waj 7 android azure-active-directory azure-ad-graph-api azure-ad-msal

将 AzureAD SSO 集成到我的 Android 应用程序中。我已在 Azure 门户上注册了一个应用程序并auth_config.json根据该应用程序获取文件。按照文档中所述逐步实现示例代码。但出现以下错误。

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.poras.testapp/com.poras.testapp.MainActivity}: java.lang.IllegalStateException: Intent filter for: BrowserTabActivity is missing.  Please refer to the MSAL readme.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3086)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3229)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:6981)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
     Caused by: java.lang.IllegalStateException: Intent filter for: BrowserTabActivity is missing.  Please refer to the MSAL readme.
        at com.microsoft.identity.client.PublicClientApplication.checkIntentFilterAddedToAppManifest(PublicClientApplication.java:1263)
Run Code Online (Sandbox Code Playgroud)

下面是我的应用程序的AndroidManifest.xml& auto.config.json

<!--Intent filter to capture System Browser calling back to our app after Sign In-->
        <activity android:name="com.microsoft.identity.client.BrowserTabActivity">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <!--Add in your scheme/host from registered redirect URI-->
                <data android:scheme="msauth"
                    android:host= "com.poras.xxxxxxx"
                    android:path= "/vhhxxxxxxxxxxxxxxpqm0=" />
            </intent-filter>
        </activity>
Run Code Online (Sandbox Code Playgroud)

自动配置.json

{
  "client_id" : "dxxxxxxxxxxxxxxxx3",
  "authorization_user_agent" : "DEFAULT",
  "redirect_uri" : "msauth://com.poras.xxxxxx/vhhxxxxxxxxxxxxxpmq0%3D",
  "authorities" : [
    {
      "type": "AAD",
      "audience": {
        "type": "AzureADandPersonalMicrosoftAccount",
        "tenant_id": "common"
      }
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我不知道我错过了什么。

Yum*_*nc. 5

如果您的清单中没有该代码段,则会出现此错误。

因此,请确保它与Microsoft网站所述完全一致,并将您的配置详细信息放置在正确的位置。并确保您拥有准确的包名称- 就像清单标记内的包属性一样,以及为您提供的准确的签名哈希。我建议您从Microsoft 门户复制代码段(即https://ms.portal.azure.com/?feature.broker=true#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview)。单击“应用程序注册”后,选择您的应用程序。从“管理”部分中的“Android”下的“身份验证”链接;单击“快速入门”以获取针对您的应用程序个性化的确切代码。(这将包含您的包名称(如果输入正确)和您的签名哈希值正确。)

同样,如果需要,请将代码插入清单中:

<!--Intent filter to capture System Browser or Authenticator calling back to our app after sign-in-->
<activity
android:name="com.microsoft.identity.client.BrowserTabActivity">
<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="msauth"
        android:host="Enter_the_Package_Name"
        android:path="/Enter_the_Signature_Hash" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

(代码摘自: https: //learn.microsoft.com/en-ca/azure/active-directory/develop/tutorial-v2-android

  • 它已经显现出来了。但它随机给出一个错误。如何修复它? (4认同)
  • @RonakGadhia 你有没有得到同样的解决方案,我面临着同样的问题。 (3认同)
  • 我面临同样的问题,你设法解决了吗? (2认同)