Base solution for your next web application
Open Closed

Xamarin App Initial Setup #7213


User avatar
0
avadhutkore created

Hi Support Team,

I was able to successfully setup the API and Angular project on my machine. But I am facing issues while setting up the Xamarin Mobile app, am getting the following error message:

I am using Visual Studio 2019 and running the mobile app on Emulator. I need your help for setting up the Xamarin Mobile App.

Thanks & Regards, Prabhat


16 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, please share your ANZ angular version.

    is your API project running at http://10.0.2.2:22742 ?

    also, please share the full error stacktrace.

  • User Avatar
    0
    alper created
    Support Team

    It seems to be a Xamarin bug... Close Visual Studio, delete all BIN & OBJ folders and rebuild the project.

  • User Avatar
    0
    avadhutkore created

    Hi,

    I have download the Latest v7.0.0 from the Download page (I guess this is what you mean by ANZ angular version).

    My API project is running at http://192.168.0.103:22742 , I had already tried by changing the following constant in the Xamarin App: private const string LocalhostIp = "192.168.0.103"; It also gave the same exception.

    I just have the exception details as shown in the Emulator snapshot above.

    Closing the visual studio and deleting the bin & obj folder did not work as well.

  • User Avatar
    0
    avadhutkore created

    Hi Support Team,

    I cached the excpetion, following is the stack trace:-

    at Flurl.Http.FlurlRequest.HandleExceptionAsync (Flurl.Http.HttpCall call, System.Exception ex, System.Threading.CancellationToken token) [0x0011d] in <7be22aadf26d4808b35d54cc18db202b>:0 at Flurl.Http.FlurlRequest.SendAsync (System.Net.Http.HttpMethod verb, System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken, System.Net.Http.HttpCompletionOption completionOption) [0x003a1] in <7be22aadf26d4808b35d54cc18db202b>:0 at Flurl.Http.FlurlRequest.SendAsync (System.Net.Http.HttpMethod verb, System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken, System.Net.Http.HttpCompletionOption completionOption) [0x004bb] in <7be22aadf26d4808b35d54cc18db202b>:0 at Flurl.Http.HttpResponseMessageExtensions.ReceiveJson[T] (System.Threading.Tasks.Task`1[TResult] response) [0x0006e] in <7be22aadf26d4808b35d54cc18db202b>:0 at PinkWish.ApiClient.AbpApiClient.GetAsync[T] (System.String endpoint, System.Object queryParameters, System.String accessToken, System.Boolean stripAjaxResponseWrapper) [0x0007e] in F:\ShoppingApp\PinkWish\aspnet-core\src\PinkWish.Application.Client\ApiClient\AbpApiClient.cs:206 at PinkWish.ApiClient.AbpApiClient.GetAnonymousAsync[T] (System.String endpoint) [0x00029] in F:\ShoppingApp\PinkWish\aspnet-core\src\PinkWish.Application.Client\ApiClient\AbpApiClient.cs:190 at PinkWish.Configuration.UserConfigurationService.GetAsync (System.Boolean isUserLoggedIn) [0x000cd] in F:\ShoppingApp\PinkWish\aspnet-core\src\PinkWish.Application.Client\Configuration\UserConfigurationService.cs:29

  • User Avatar
    0
    alper created
    Support Team

    how do you start your host? If you run the host from Visual Studio, you cannot connect to it. you need to run the host from command line withdotnet run. Check out the debugging section https://docs.aspnetzero.com/documents/aspnet-core-angular/latest/Development-Guide-Xamarin#host

  • User Avatar
    0
    avadhutkore created

    I am starting the Host from Command line only, by running the follwoing commands:

    SET ASPNETCORE_ENVIRONMENT=Development SET ASPNETCORE_URLS=http://*:22742 dotnet run

  • User Avatar
    0
    alper created
    Support Team

    I see http://10.0.2.2:22742 URL in your screenshot.


    you have to write your local IP here


  • User Avatar
    0
    avadhutkore created

    Hi,

    I have already tried with both IP Addresses: -

    1. Emulators.Andorid (Which is 10.0.2.2 as shown in the screenshot)
    2. 192.168.0.103 (screenshot is not attached) Both gives the same exception.

    I am using the Android Emulator, so will set the the IP as follows: private const string LocalhostIp = Emulators.Android;

    I am following the setup document and had tried these things already except opening the API project from Mobile browser. I will try that and will let you know the result. Thanks for your help !!

  • User Avatar
    0
    alper created
    Support Team
    private const string LocalhostIp = --use your local computer IP address--
    

    and also try to access the URL from mobile browser. lastly try to use with a real Android device

  • User Avatar
    0
    avadhutkore created

    From the mobile Emulator browser I can access the API URL:

    To access it from real Android device, do i need to deploy the APP on mobile or is there any other option?

  • User Avatar
    0
    avadhutkore created

    I have tried with the real android device, it is also giving the same "class not found exception". Could it be because of the Visual studio 2019 Community Edition?

  • User Avatar
    0
    alper created
    Support Team

    I think your problem is not related to network.

    disable linker and try again https://docs.microsoft.com/en-us/xamarin/android/deploy-test/linker#linker-behavior

  • User Avatar
    0
    alper created
    Support Team

    also see this post https://support.aspnetzero.com/QA/Questions/6025#answer-ead76bf3-b751-dbfe-9bbd-39ea6b7d07ce

  • User Avatar
    0
    avadhutkore created

    Disabling linker did not work as well.

  • User Avatar
    0
    avadhutkore created

    I Downgraded the visual studio from VS2019 to VS 2017 and it is working fine in Visual studio 2017 community edition. This is kind of workaround for using the ANZ code. Do let me know if you guys can suggest anything to make it working in visual studio 2019.

  • User Avatar
    0
    alper created
    Support Team

    I'm also using VS2019 without any problem. Reinstall your Visual Studio 2019 with full Xamarin features.