Solved the root cause of this problem by just upgrading the Microsoft.Azure.Mobile.Client and Microsoft.Azure.Mobile.Client.SQLiteStore libraries from v.4.1.2 to v.4.2.0 and I no longer get the crash
"Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference" when authenticting user on Android
Authenticating the user (using azure authentication provider) works fine. However, when the app is terminated and then launched, we are authenticating the user again and then we get the error Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
When trying to authenticate again right after, it crashes with the error message System.InvalidOperationException: Authentication is already in progress.
Example code:
try
{
ProviderHelper provider = ProviderHelper.Google;
var user = await AllInclusive.App.Client.LoginAsync(this, (MobileServiceAuthenticationProvider)provider, "myAppName");//crashes here
}catch(Exception e)
{
//first login when the app is launched after it has been terminated, we get the Java.Lang.NullPointerException error.
//when trying to login again, it crashes again with the error message "System.InvalidOperationException: Authentication is already in progress."
var messahe = e.Message;
}
What is the cause of the Java.Lang.NullPointerException error, do I need to create a new context for android when authenticating again? Any solutions for that error?