How can I debug Visual Studio - Xamarin.Forms project on Android device?

痴心易碎 提交于 2019-12-12 03:49:30

问题


I want to attach the Android device to Windows 8.1 trough USB instead of using the built in emulator.

How can I do this?

Note : The device can be connected trough USB (USB drivers are installed),
and its in devaloper mode.


回答1:


  • You first need to enable Developer Mode:

Android 4.2 and higher

Starting in Android 4.2 and higher, the Developer options is hidden by default. To make it available, go to Settings > About phone, and tap the Build number item seven times to reveal the Developer Options tab:

Xamarin's doc: Set Up Device for Development

  • Then you need USB drivers for your phone if you already do not have them installed, check Sony's support site.

Once your device is connected to your machine via the USB cable, debugging is just like debugging via an emulator.

Start debugging your application by pressing Cmd-Enter in Xamarin Studio on OS X or F5 in Visual Studio. When you do so, you may be prompted to choose the device to debug with.

Xamarin's doc: Debug on Device

Check that your device is showing up for Android's adb:

1) Find where Visual Studio/Xamarin (or you) installed the Android SDK:

(Click 'Tools' in the toolbar at the top, then click 'Options')

2) Copy the the path for Android SDK Location

3) Paste that into your shell (cmd or powershell) proceeded by cd (we need to change to that directory.

4) CD into the platform-tools subdirectory

5) Run adb devices

This should display something like:

List of devices attached
XXX12345    device

If all that is returned:

List of devices attached

Then the device is not been recognized and will not be available for Xamarin (or any of the Google Android tools) to deploy.

Note: Also check to ensure that your phone is in Mass Storage mode, as some default to MTP mode and that will not work as an adb device

Note: If it’s NOT appearing in the list make sure that drivers are properly installed and you’ve enabled “USB Debugging" on the phone




回答2:


You need to enable USB debugging in Developer Options in your phone, plug your phone and it should be detected by Visual Studio.

You may also need to download and install USB Drivers from Sony Drivers page



来源:https://stackoverflow.com/questions/36666105/how-can-i-debug-visual-studio-xamarin-forms-project-on-android-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!