如何在Android设备上调试Visual Studio-Xamarin.Forms项目? [英] How can I debug Visual Studio - Xamarin.Forms project on Android device?

查看:582
本文介绍了如何在Android设备上调试Visual Studio-Xamarin.Forms项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过USB将Android设备连接到Windows 8.1 而不是使用内置的模拟器.

我该怎么做?

注意:可以通过USB连接设备(已安装USB驱动程序),
及其处于devaloper模式.

解决方案

  • 您首先需要启用开发人员模式:

Android 4.2及更高版本

从Android 4.2及更高版本开始,默认情况下隐藏开发人员"选项.要使其可用,请转到设置">关于手机",然后点击内部版本号"项七次以显示开发人员选项"标签:

Xamarin的文档:设置开发设备

  • 然后,如果您尚未安装USB驱动程序,则需要手机的USB驱动程序,请访问Sony的支持网站.

将设备通过USB电缆连接到计算机后,调试就像通过模拟器进行调试一样.

通过在OS X上的Xamarin Studio中按Cmd-Enter或在Visual Studio中按F5开始调试应用程序.这样做时,系统可能会提示您选择要调试的设备.

Xamarin的文档:在设备上调试

检查您的设备是否显示为Android的adb:

1)找到Visual Studio/Xamarin(或您)在何处安装了Android SDK:

(单击顶部工具栏中的工具",然后单击选项")

2)复制Android SDK位置的路径

3)将其粘贴到您的外壳(cmd或powershell)中,然后按cd键(我们需要切换到该目录.

4)将CD放入platform-tools子目录

5)运行adb devices

这应该显示如下内容:

List of devices attached
XXX12345    device

如果返回的全部内容:

List of devices attached

然后无法识别该设备,并且Xamarin(或任何Google Android工具)将无法使用该设备.

注意:还请检查以确保手机处于Mass Storage模式(某些默认设置为MTP模式),并且不能作为adb设备使用

注意:如果未出现在列表中,请确保已正确安装驱动程序,并且您已在手机上启用"USB调试"

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.

解决方案

  • 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

这篇关于如何在Android设备上调试Visual Studio-Xamarin.Forms项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆