Base solution for your next web application
Open Closed

App crashing in LoadPersistedSession() #9826


User avatar
0
chrskrs created

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version? : 9.1.2
  • What is your product type (Angular or MVC)? MVC
  • What is product framework type (.net framework or .net core)? net core

If issue related with ABP Framework

  • What is ABP Framework version? 9.1.2

Hi, we have a weird problem in our xamarin android application.

On emulators the app works fine but on a device (several tried), If I run the my app in DEBUG mode it works fine.

If I run the app in RELEASE mode the app craches upon startup. I have traced the error to the call to LoadPersistedSession() in the SplashActivity. If I comment this (LoadPersistedSession) out and rerun the app it then works. I have to log in every time however. (for this app this is not acceptable);

I have also observed that this only happens when you have multi-tenancy enabled. Can you please investigate and help.

we have had this problem on a version 8.5 framework as well but there we could leave the line commented out, however im this app we need to remember the last login.


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @chrskrs

    1. This might be related to app permissions. Did you grant all permissions during app's first initialization ?
    2. Do you also have this line https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Mobile.Droid/Properties/AndroidManifest.xml#L6 in your manifest file ?

    Thanks,

  • User Avatar
    0
    alper created
    Support Team

    Can you replace LoadPersistedSession method with the following So that we can understand what's the exception.

    Mobile.Shared > App.xaml.cs

            public static void LoadPersistedSession()
            {
                var step = 0;
    
                try
                {
                    var accessTokenManager = DependencyResolver.Resolve<IAccessTokenManager>();
                    var dataStorageService = DependencyResolver.Resolve<IDataStorageService>();
                    var applicationContext = DependencyResolver.Resolve<IApplicationContext>();
                    step = 1;
    
                    accessTokenManager.AuthenticateResult = dataStorageService.RetrieveAuthenticateResult();
                    step = 2;
    
                    applicationContext.Load(dataStorageService.RetrieveTenantInfo(), dataStorageService.RetrieveLoginInfo());
                    step = 3;
    
                }
                catch (Exception e)
                {
                    UserDialogs.Instance.Alert("Error step: " + step + ". Ex: " + e.ToString());
                }
            }
    
  • User Avatar
    0
    alper created
    Support Team

    @chrskrs wrote :

    In UserConfigurationManager.GetIfNeedsAsync(), the following code is executed:

            await WebRequestExecuter.Execute(
                async () => await userConfigurationService.GetAsync(AccessTokenManager.IsUserLoggedIn),
                async result =>
                {
                    AppContext.Value.Configuration = result;
                    SetCurrentCulture();  
    

    RELEASE MODE : result = null !!!! DEBUG MODE: result has a value

    The app fails during this call : SetCurrentCulture(); I do not know whether this has to do with the null result in AppContext.Value.Configuration Unfortunately I do not know how to debug SetCurrentCulture(); as iI cannot make the call async and then the messages do not show

    But I am fairly sure the error occurs in SetCurrentCulture() . ( UserConfigurationManager.cs)

  • User Avatar
    0
    alper created
    Support Team

    firstly, you must run in Debug mode. Xamarin needs extra configuration for running in release mode...

    Check that you have enabled "Use shared runtime"

    result is null because it cannot get a response with the existing token.the host address maybe incorrect!

    Did you configure DefaultHostUrl when you run it in Release mode.

    check the host address in your device mobile browser that you can reach it.

  • User Avatar
    0
    alper created
    Support Team

    hi,

    you cannot run it in release mode, you can only run it in debug mode. if you want to see it in release mode, then you need to publish it as an APK. See https://support.aspnetzero.com/QA/Questions/5936/Build-Project-in-Release-Mode https://support.aspnetzero.com/QA/Questions/5346/deploying-mobile-app#answer-82a79ec1-b7dd-481b-a888-055862ffdb9a