Service not registered: com.microsoft.identity.common.internal.ui.browser.CustomTabsManager$1@4af7a6e

Viewed 125

I am using msal library in an android app and this crash is occurring on many devices

My user agent cannot be WEBVIEW

Fatal Exception: java.lang.IllegalArgumentException: Service not registered: com.microsoft.identity.common.internal.ui.browser.CustomTabsManager$1@4af7a6e
       at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1160)
       at android.app.ContextImpl.unbindService(ContextImpl.java:1475)
       at android.content.ContextWrapper.unbindService(ContextWrapper.java:644)
       at com.microsoft.identity.common.internal.ui.browser.CustomTabsManager.unbind(CustomTabsManager.java:164)
       at com.microsoft.identity.common.internal.ui.browser.BrowserAuthorizationStrategy.dispose(BrowserAuthorizationStrategy.java:182)
       at com.microsoft.identity.common.internal.ui.browser.BrowserAuthorizationStrategy.completeAuthorization(BrowserAuthorizationStrategy.java:157)
       at com.microsoft.identity.common.internal.controllers.LocalMSALController.completeAcquireToken(LocalMSALController.java:258)
       at com.microsoft.identity.common.internal.commands.InteractiveTokenCommand.notify(InteractiveTokenCommand.java:77)
       at com.microsoft.identity.common.internal.controllers.CommandDispatcher.completeInteractive(CommandDispatcher.java:608)
       at com.microsoft.identity.common.internal.controllers.CommandDispatcher.access$1100(CommandDispatcher.java:83)
       at com.microsoft.identity.common.internal.controllers.CommandDispatcher$4$1.onReceive(CommandDispatcher.java:565)
       at androidx.localbroadcastmanager.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:313)
       at androidx.localbroadcastmanager.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:121)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:7325)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

here's my json config file.

  "client_id": "client_id",
  "authorization_user_agent": "BROWSER",
  "account_mode": "MULTIPLE",
  "redirect_uri": "redirect_uri",
  "authorities": [
    {
      "type": "B2C",
      "authority_url": "authority_url",
      "default": true
    },
    {
      "type": "B2C",
      "authority_url": "authority_url"
    }
  ],
  "browser_safelist": [
    {
      "browser_package_name": "com.mi.globalbrowser",
      "browser_signature_hashes": [
        "g7zGEnZipieE6ZyBA4Bz00kxU8h0F9QTwPLL-dnRVwngI0FJWJiD3rCEJsIQ_VK064SNdxzqggnnnAqT8LI89A=="
      ]
    }
  ]
}

And here's a list of some devices where the crash occurs

moto g(6) play

moto z3 play

Moto G(4) Plus

LG K40S

LG Q60

ZenFone Max Shot (ZB634KL)

and many other not listed here, including xiaomi, samsgung and onePlus

2 Answers

I updated MSAL to version 2.2.1 and now it is working fine.

This is the known bug in the microsoft-authentication-library-for-android.

You can authenticate by edit the auth_config.json file in the Raw folder and change the user agent to this authorized_user_agent : WEBVIEW.

You can authenticate the user using the Webview instead of the browser and from this way your app will not be crashed.

Look into this pull-request.

Related