Reputation: 4847
I have a Xamarin application which creates a GoogleApiClient and calls EnableAutoManage. When my app runs, I am asked which user account to use, and then the app hangs on a blank popup page with a Google-themed spinner. Why is this happening?
I have been following this video which shows how to set up an application's to read Google Fit data. Notice the timestamp - this is where the code is presented.
https://youtu.be/j_zsNxMI6jI?t=2172
I have followed the examples here, and have narrowed the problem to this piece of code:
// In my MainActivity's OnCreate:
try
{
int defaultClientId = 0;
googleApiClient = new GoogleApiClient.Builder(this)
.AddApi(FitnessClass.HISTORY_API)
.AddApi(FitnessClass.RECORDING_API)
.AddScope(FitnessClass.ScopeActivityRead)
.EnableAutoManage(this, defaultClientId,
result =>
{
int m = 3; // Breakpoint here is never hit
})
.Build();
}
catch (Exception e)
{
int m = 3; // Breakpoint here is never hit either
}
If I run my app (tried on both emulator and physical hardware), I am first asked which account to use.
After selecting the account, another popup appears with a Google-themed (changing between red, yellow, green, and blue) spinner at the top. The popup stays on screen and the spinner animates indefinitely.
As noted in the code above, no exceptions are raised, and no result is returned in the EnableAutoManage delegate. Why is this happening?
If I remove the following line, the app no longer shows a spinner indefinitely:
.AddScope(FitnessClass.ScopeActivityRead)
The addition of this line of code seems to be the cause of the popup with the spinner.
I thought I'd try the "new" approach of using GoogleApi rather than GoogleApiClient as explained here:
https://android-developers.googleblog.com/2017/11/moving-past-googleapiclient_21.html
Unfortunately, there seem to be no Xamarin bindings for this yet:
Xamarin Android: Cannot resolve GoogleSignIn and GoogleSignInClient
Upvotes: 1
Views: 112
Reputation: 4847
The reason this happened is because my google account hadn't yet been added as a test user. One might expect that Google would provide some kind of useful feedback through a popup, but instead it provided an empty page.
To solve this problem:
Now the app should properly display a confirmation page.
Upvotes: 1