Null allowableAccounts arg AccountManager.NewChooseAccountIntent causes exception in Xamarin 4.8

The following code results in an ArgumentNullException (full logcat output attached) since upgrading to Xamarin.Android 4.8. I have double checked and exactly the same code running on exactly the same devices works perfectly fine when compiled against a prior version of Xamarin.Android.

var intent = AccountManager.NewChooseAccountIntent(
    null, // allowableAccounts, optional, but now causes exception if null
    new[] { Authenticator.AccountType },

activity.StartActivityForResult(intent, requestCode);

I can also confirm that the error does not occur if a non-null, non-empty Account[] array is provided for the ‘allowableAccounts’ parameter--but this results in filtering which is not the desired behaviour in our case.


  • Did you find a solution to this problem ?

  • DavideMendoliaDavideMendolia USMember
    edited November 2013

    It's a little annoying but I used this.

    Intent intent = AccountPicker.NewChooseAccountIntent(null, AccountManager.Get(this).GetAccounts(), new String[]{""}, false, null, null, null, null);

  • I previously ran into several other issues involving bindings that use various collection types as arguments.

  • Davide:

    I worked around the problem in essentially the same way as you did, the only exception being that I used AccountManager.GetAccountsByType() (obviously the end result is the same since the third parameter filters the account by type anyway).


    I wasn't using any other APIs with collection parameters at the time, but it did look to me like a general regression in the SDK bindings in that release of Xamarin.Android (4.8) since there's nothing in the release notes that suggests this particular method would have changed in any way (and the same code compiled with an older version of Xamarin.Android on exactly the same device works correctly)

Sign In or Register to comment.