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

Issue

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

Solution

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

Answered By – Marcelo Esser

Leave a Comment