xamarin.andriod connect to web api - xamarin.forms

I am currently working on a Xamarin project for Mac and Android mobile devices. I am using Visual studio for mac to create the xamarin project. In my application I have to invoke a Webservice endpoint. As I am still at early stages; both the
Webservice and the Xamarin mobile application are running locally on my machine. When I try to call the Webservice from Xamarin the base url works fine on mac as http://localhost:5000. However when I run android version, I am unable to connect to my local webservice using http://localhost:5000. Is there any workaround for this?
After researching, I have also tried using the following base uri's:
http://10.0.2.2:5000
I have also right-clicked on the project and under Build I went to Android Build. Underneath Code Generation and Runtime I selected Managed (HttpClientHandler) for the option HttpClient implementation. As well as SSL/TLS implementation for the option Native TLS 1.2+.

Related

Xamarin App crashes after testFlight release before my code runs

Hello and thank you for reading.
This is my first time publishing an ios application and I am using Xamarin to publish my app to both Android and iOS (as requested by the client ).
Now the application deploys and works correctly when I run it via visual studio/Rider but when I push it to testflight (via azure pipeline and microsoft App Center) I get the following Crash report:
link to crashreport
oke so after some triel and error I have found the problem:
Apparently in Xamarin if you use EFCore then there is the possibility of mTouch to skip the reflections used by it
more info (and my saving grace) was found here:
https://learn.microsoft.com/en-us/ef/core/get-started/xamarin#explore-the-code

Debug a real Android device using Xamarin for Visual Studio

I'm a beginner in mobile development, and I'm developing an application in Xamarin.Android with Visual Studio 2019, with SQLite and the MVVM pattern. The project structure is simple, I'm not using API's or external services. For debugging, I'm trying to use my physical device (Android 9.0 - API 28, Itel S15 tag), but unfortunately the following error message is returned in Visual Studio (Debug output):
Forwarding debugger port 8865
Failed to launch android application
it's the first time i've tried this, i've always debugged in an installed emulator,I have USB debugging enabled as well as developer mode on the physical device. I've done a lot of research and I can't find anything specific to my problem. Please any ideas?
Before debugging can occur on a device, it must be setup for development and connected to your PC or Mac.
Here are documents about how you can set up the device and how to debug on device
https://learn.microsoft.com/en-us/xamarin/android/get-started/installation/set-up-device-for-development
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/debugging/debug-on-device?tabs=windows

Qt mobile app client w/ SignalR .NET server

I'm planning to build Web application and use the SignalR library to allow web admin to chat with other users (use Mobile application)
1- System admin uses Web Application built by Asp.net Boilerplate (.NET Core 3.1).
2- other users use Mobile Application built by (Qt Mobile application )
So, Is this scenario applicable with the SignalR library, or I will encounter some limitations especially with QT Mobile application?
Update:
Why I want this approach?
Because I'm using Esri QML SDK (in Mobile App)
I am not familiar with QT Mobile Application development, however I looked for it and understood that the language of development is C++.
Based on this, here is a client lib for SignalR in C++. You can use this lib to connect to c++
Click Here
Also, I wish to bring attention to an official documentation from Microsoft that states that C++ & Swift are unofficially supported framework.
Link
I have not used SignalR before. However, Qt provides its own websocket QML client component as well as a server one, they have a client example here and a server example here should you want to see how the client component interacts.
I have used the QML websocket with a NodeJs websocket server and it presented no problems at all.
Creating a simple working environment should be no problem, Qt provides its own simulator with their IDE, just copy the client example, change the link to point to your server and give it a shot.
If you haven't got this up and running by now, I'll suggest you would take a look at signalr-qt. We have been using this for several years now, with Qt apps for iOS, Android and Windows desktop. Unfortunately it is not maintained anymore, but we've been running it in production apps using Qt 5.6, Qt 5.12 and Qt 5.15.

deploying Xamarin forms application to android phone

I am very new to xamarin forms. I developed a simple autocomplete application in Xamrin forms using Visual studio 2017 enterprise version. I want to deploy that application to android phones. When I created the application, I selected Cross Platform app (xamarin.forms or Native). below is the image of visual studio run button:
and the properties of the project are below:
any article or any steps to deploy this application to android phones will be highly appreciated.
Set Up Device for Development - source - https://developer.xamarin.com
Enable Debugging on the Device - By default, it will not be possible to debug applications on a Android device.
Install USB Drivers - This step is not necessary for OS X computers. Windows computers may require the installation of USB drivers.
Connect the Device to the Computer - The final step involves connecting the device to the computer by either USB or WiFi.
Once a device is connected to your computer you will see your device like this
Now Click the green arrow to start deploy and debug.
additional - This link will show you how to debug and prepare APK for release
https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/

Android Debugging Failing With "Couldn't connect to logcat, GetProcessId returned: 0" FFImageLoading.Platform.dll.so Not Found

I am having issue debugging Android project. I can deploy to device and run it, all works fine but if I try to debug, the app gets deployed to the device and very briefly opened, splash screen shows up but the app then closes.
I am using Xamarin Forms on Visual Studio 2015.
Device is running Android Oreo (8.0.0). Another device running Android 6.0.1 is debugging fine.
The output shows following:
InspectorDebugSession(11): StateChange: Start -> EntryPointBreakpointRegistered
InspectorDebugSession(11): Constructed
Android application is debugging.
InspectorDebugSession(11): HandleTargetEvent: TargetExited
InspectorDebugSession(11): Disposed
Couldn't connect to logcat, GetProcessId returned: 0
I checked Logcat and it seem to be having issues finding FFImageLoading library:
Time Device Name Type PID Tag Message
09-18 14:35:52.361 Huawei Nexus 6P Debug 1560 Mono AOT:
image '/usr/local/lib/mono/aot-cache/arm/FFImageLoading.Platform.dll.so'
not found: dlopen failed: library "/data/app/myapp.android.dev-
WEb1bz8edgF7vwx6uCoZ-A==/lib/arm/libaot-FFImageLoading.Platform.dll.so" not found
I have added Nuget package for FFImageLoading to my projects and Droid project references show it as in image below:
This worked for me :-
Deselecting the 'Use Shared Runtime' in Project Properties > Android
Options > Packaging properties
I also had this issue with Android 8.1 and Visual Studio 2017 15.7.4.
There are three steps to got it working again.
Under Android Options, go to Advanced and add your device architecture, in my case it was x86_64.
Go to Tools -> Options -> Xamarin > Android Settings and enable: Provide debug symbols for shared runtime and base class libraries.
And the final step is to delete following Apps from your device:
All Xamarin.Android API Support libraries
Mono Shared Runtime
Your App
After these steps you don't need to disable "Use Shared Runtime" and can Deploy and Debug much faster.
This is a known issue with Oreo and Xamarin Android on Visual Studio for Windows. It works on Visual Studio for Mac apparently. It will be fixed in an upcoming release. In the mean time there is a work around down near the bottom of the bug link above (comment 20).
deselecting 'Use Shared Runtime' in Project Properties > Android Options
delete bin & obj files from solution
clean solution
rebuild the solution it works
One another reason for that is if you dont enable usb debugging on your device, VS 2017 still recognizes your phone and installs the app on your phone. Just after debugging starts, it will throw this error and not continue debugging. Make sure to enable Developer Mode -> Usb debugging like described here
https://learn.microsoft.com/en-us/xamarin/android/get-started/installation/set-up-device-for-development

Resources