Debug a real Android device using Xamarin for Visual Studio - sqlite

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

Related

A deployment error in Xamarin.Forms UWP when deploying from a PC to itself

When I just installed a Visual Studio 2017 and created my Xamarin.Forms application, it ran fine on my Windows 10 PC. However, I then installed some apps from Steam (which is the only thing I can think of that could change system settings). After that, when I try to create another Xamarin.Forms project, it does not deploy well to my machine and gives the following error:
DEP6200: Bootstrapping failed. Device cannot be found.
SmartDeviceException - Deployment failed because no
device was detected. Make sure a device is connected
and powered on. [0x80131500]
Strangely enough, my first app continues to build and run fine, even if I uninstall it from Windows and then deploy it again.
What could be the issue?
I have just noticed that Visual Studio makes ARM the default architecture. Changing it to "Any CPU" brought back the option to run the app on my machine.

Can't debug application on IOS Device

I created a vanilla PCL project in xamarin forms. I tried to run on Android and it works fine.
But when I change de target to IOS and select my real device (Ipad with IOS 11.4.1), Visual studio only allows me to build solution, I wanna to run application on it but I can't.
The target IOS is 8.0, and I already authenticated with my apple account and created a provisioning profile.
I already done this on another project before and works fine.
I really don't know why Visual Studio don't allow me to debug, when I open my oldest project with this device it allows me to debug.
What OS are you running Visual Studio on? IOS requires MAC, whereas Android is compatible with all OS. It's been a while, but I know there's an option to wirelessly connect to a MAC OS so that you can run your IOS Xamarin Forms application anywhere.
I found the solution.
I was trying to use "Debug", and it works fine on the emulator, but to real device I need to use "Debug | Iphone" or otherwise it only builds.
Even when I try to use "Release" it's the same trick.

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

VS 2015 + Cordova + Emulator for Android = error "unable to deploy"

Using the default Blank Cordova project in VS2015 update 1, I try to publish (Debug > Android > Device) to the Android Emulator (Tools > Visual Studio Emulator for Android) and I get the following error:
Severity Code Description Project File Line Suppression State
Error Unable to deploy to Android device, no attached device was found. If you recently attached a device, you may need to wait a few seconds before it is recognized. BlankCordovaApp2
I am also getting the following error when I click Yes in the pop-up deployment errors window :
Operation not supported. Unknown error:0x80070057
Here's the device list from ADB confirming the VM is being detected.
No luck with the following.
I reinstalled Android SDK Manager and updated files.
I removed and then re-installed VS2015 community.
I can use adb.exe to check for the emulator device and it sees the device.
The android emulator appears to be working and displaying properly.
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK is pointing to the correct location
renamed CoreCon
Ran Dependency Checker (Tools > Options > Tools for Apache Cordova)
I can deploy the .apk package on the Android emulator using adb install folder\location\xxx.apk
Any thoughts?
All I had to do was enable Android USB Debug on my phone.
Go to Configuration > System > About the Phone (My Phone is in Portuguese, so the menu options may differ a little bit)
Scroll to the bottom and tap on "Version number" around 10 times
A new option called "Developer" will be available under Configuration > System. Open it
Enable USB Debugging
Deploy the app again
Windows 10, VS 2015, Cordova 6.3.1, Using Andriod 23
I hab some trouble with different adb.exe errors and i fixed all of them. Perhaps this checklist will help. (Some things were already mentioned but nevertheless^^ her is my list):
Make sure yor device is connected to your Laptop. Check this with the console command "adb devices" (you have to be in the directory where adb.exe is)
If you see more than one an emulator is running , kill him (restart pc) if you see nothing check out another usb cable.
DELETE the app from your phone e.g. if you changed developing machine.
When installing MS Visual Studio you can first uncheck all and then only check Javascript->Cordova. Setup will make the rest. But install node.js and andriod-sdk (only sdk not the wohle andriod development studio... no need)
with the Andriod SDK-Manager make sure you have "Andriod sdk build tools" ONLY for your version installed.... for me 23.. AND Extras->"Andriod Suppot Repository" i have it like this:
here you can see my SDK Manager Part 1
here you can see my SDK Manager Part 2
5.Make sure you have developer options activated on phone and USB-Debugging is enabled. And on startup make sure you allow access from the Machine e.g. laptop to your device e.g. phone. A prompt should appear on your device.
cya
I encountered a similar problem.
Solution:
1)Open Developer tools in android devices and Revoke USB debugging authorizations
2)Then restart USB debugging
I was able to resolve this by editing the config.xml file and changing the Target API Level to match the installed version of the Android OS on my phone for development. Here is a link to the google developer docs:
https://developer.android.com/about/versions/marshmallow/android-6.0.html
It contains info on backward compatibility to help with setting the version appropriately.
Here's a work around to my problem. It doesn't fix the original problem, but it does allow me to debug using the Visual Studio Emulator for Android
Work Around:
Use the Debug > Android > VS Emulator XXX in the drop down to open the emulator and debug. VS Emulators can be added by using Tools > Visual Studio Emulator for Android
Previous Workflow:
Open Tools > Visual Studio Emulator for Android
Launch the Device Profile
Wait for the Device Emulator to open
Debug the project by using Debug > Android > Device
Close VS
Open it as Administrator
Tools > Visual Studio Emulator for Android
Start an emulator
Voilá
It worked for me

Resources