Visual Studio 不允许我在 android 物理设备上调试

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25888188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:47:48  来源:igfitidea点击:

Visual Studio doesn't let me debug on android physical device

androiddebuggingvisual-studio-2013adb

提问by nix86

I'm developing an android app with Xamarin and Visual Studio 2013. I have connected my android applet to the computer. Sansung Kies recognizes the device. Adb recognizes it also because when I type "adb devices" the device appears in the list. But when I debug the app Visual Studio doesn't let me choose my device, it only proposes to me to use the android virtual emulator. In my device the "USB debug" option is enabled. So what am I doing wrong?

我正在使用 Xamarin 和 Visual Studio 2013 开发一个 android 应用程序。我已将我的 android 小程序连接到计算机。Sansung Kies 识别该设备。Adb 也能识别它,因为当我输入“adb devices”时,该设备会出现在列表中。但是当我调试应用程序时,Visual Studio 不允许我选择我的设备,它只建议我使用 android 虚拟模拟器。在我的设备中,启用了“USB 调试”选项。那么我做错了什么?

回答by chriszumberge

EDIT

编辑

Just got a new machine and ran into the same problem.

刚买了一台新机器,遇到了同样的问题。

Following these steps: http://visualgdb.com/KB/usbdebug-manual/as suggested by Veverke in the comment below fixed the issue for me.

按照以下步骤操作:http: //visualgdb.com/KB/usbdebug-manual/ 正如 Veverke 在下面的评论中所建议的那样为我解决了这个问题。



just had the same issue and fixed it with a combination of these two links. Obviously our issue isn't the exact same issue that's listed in the first link but that's why I had to use both to kind of synthesize a solution.

刚刚遇到了同样的问题,并通过这两个链接的组合修复了它。显然,我们的问题与第一个链接中列出的问题不完全相同,但这就是我必须同时使用两者来综合解决方案的原因。

https://web.archive.org/web/20140410204811/http://krumelur.me/2014/01/30/xamarins-visual-studio-plugin-missing-android-devices-genymotion-and-parallels-desktop-dont-panic/

https://web.archive.org/web/20140410204811/http://krumelur.me/2014/01/30/xamarins-visual-studio-plugin-missing-android-devices-genymotion-and-parallels-desktop-不要恐慌/

http://developer.android.com/tools/extras/oem-usb.html

http://developer.android.com/tools/extras/oem-usb.html

Basically, in Visual Studio 2013 start the Android SDK Manager. Scroll all the way down to the 'Extras' folder, where you will find the 'Google USB Driver'. Mine was already installed, so I deleted the package, confirmed I wanted it deleted, then reinstalled it.

基本上,在 Visual Studio 2013 中启动 Android SDK Manager。一直向下滚动到“Extras”文件夹,您将在其中找到“Google USB 驱动程序”。我的已经安装了,所以我删除了这个包,确认我想删除它,然后重新安装它。

Then, I opened Windows Explorer and right clicked 'Computer', then clicked 'Manage' (need Admin priviledges). In the newly opened Computer Management window I clicked 'Device Manager' under Computer Management > System Tools in the hierarchy on the left.

然后,我打开 Windows 资源管理器并右键单击“计算机”,然后单击“管理”(需要管理员权限)。在新打开的计算机管理窗口中,我单击左侧层次结构中计算机管理 > 系统工具下的“设备管理器”。

In the main window, I expanded 'Other Devices' and saw the device I was looking for. I right-clicked it and chose 'Update Driver Software', then 'Browse my computer for driver software'.

在主窗口中,我展开“其他设备”并看到我正在寻找的设备。我右键单击它并选择“更新驱动程序软件”,然后选择“浏览我的计算机以查找驱动程序软件”。

Now you need to hit Browse...and find where you installed the packages.. for myself it was under C:\Users\zumberge\AppData\Local\Android\android-sdk\extras\google\usb_driver. Click next, the you need to choose to accept Google, Inc. as a trusted source. Then the process should be finished and you'll be good to go.

现在你需要点击Browse...并找到你安装软件包的位置......对我自己来说它在 C:\Users\zumberge\AppData\Local\Android\android-sdk\extras\google\usb_driver. 单击下一步,您需要选择接受 Google, Inc. 作为可信来源。然后这个过程应该完成,你就可以开始了。

Don't know if you need to restart VS2013, but I did for good measure.

不知道你是否需要重新启动 VS2013,但我做了很好的措施。

Hope this helps and it's not too late.

希望这会有所帮助,现在还为时不晚。

回答by Hassan Rahman

For VS 2015, LG Nexus 4 and Windows 7, following solution works for me.

对于 VS 2015、LG Nexus 4 和 Windows 7,以下解决方案适用于我。

Debugging On and Off during the running instance of Visual Studio, your physical device appears in the device list.

在运行 Visual Studio 实例期间打开和关闭调试,您的物理设备会出现在设备列表中。

enter image description here

enter image description here

回答by akaltar

Also make sure you have the correct configuration selected for your device. (eg. ARM for most smartphones)

还要确保为设备选择了正确的配置。(例如,适用于大多数智能手机的 ARM)

If its set to one that your device doesn't support, then the device won't show up even if adb can see it. Simply switching the configuration solved the problem for me.

如果它设置为您的设备不支持的设备,那么即使 adb 可以看到该设备也不会显示。简单地切换配置为我解决了这个问题。

回答by summerGhost

I just ran adb command prompt and hit 'adb devices' and it showed daemon was not running. It installed itself and now i can able to see android devices there.

我只是运行 adb 命令提示符并点击“adb devices”,它显示守护进程没有运行。它自行安装,现在我可以在那里看到 android 设备。

C:\...\...\source\repos\ABC\ABC\Ex.Android>adb devices
List of devices attached
* daemon not running; starting now at tcp:5037
* daemon started successfully
ZF22Q3T      unauthorized

回答by phoad

Restart of Visual Studio 2013 has resolved the issue for me.

重新启动 Visual Studio 2013 为我解决了这个问题。

Details:

细节:

  • Visual Studio was open while I was trying to make the device visible to the system.
  • After installing the device driver, I have restarted the "adb" and saw that the device is added to the list "adb devices".
  • However the name of the device at the Visual Studio was not changed, some numbers.
  • After restarting the Visual Studio, real name of the device is shown "NVIDIA Shield Android TV.."
  • 当我尝试使设备对系统可见时,Visual Studio 处于打开状态。
  • 安装设备驱动程序后,我重新启动了“adb”,看到该设备已添加到“adb devices”列表中。
  • 然而,Visual Studio 中的设备名称没有改变,只是一些数字。
  • 重新启动 Visual Studio 后,设备的真实名称显示为“NVIDIA Shield Android TV..”

Then I did not get this error anymore.

然后我就没有再收到这个错误了。

回答by Paul - Soura Tech LLC

After enabling debug mode on my android device, I found I had to change the 'USB PC Connection' option. It was set to 'Charge Device'. When I switched it to 'Media Sync (MTP)' and reconnected to my PC it then showed up in Device Manager, but the drivers did not appear to be working with VS. I reinstalled the 'Google USB Driver' in SDK Manager. I removed my device in Device Manager and added it back using the Google USB Driver. When I disconnected/reconnected the device to my PC, Windows asked what I'd like to do with the device. I realized the first time it had asked me, I quickly clicked 'Do Nothing'. This time I noticed the first option was to run an exe on the device to install the driver. After the install completed I disconnected/reconnected the device and the device prompted me to allow my PC to debug. After selecting 'Allow', the device showed up in VS while VS was already open.

在我的 android 设备上启用调试模式后,我发现我必须更改“USB PC 连接”选项。它被设置为“充电设备”。当我将它切换到“媒体同步 (MTP)”并重新连接到我的 PC 时,它会出现在设备管理器中,但驱动程序似乎无法与 VS 一起使用。我在 SDK 管理器中重新安装了“Google USB 驱动程序”。我在设备管理器中删除了我的设备,然后使用 Google USB 驱动程序将其添加回来。当我将设备断开/重新连接到我的 PC 时,Windows 询问我想用该设备做什么。我意识到它第一次问我时,我很快点击了“什么都不做”。这次我注意到第一个选项是在设备上运行一个 exe 来安装驱动程序。安装完成后,我断开/重新连接设备,设备提示我允许我的 PC 进行调试。选择“允许”后,设备出现在 VS 中,而 VS 已经打开。

回答by InnerSpace

I followed most of the steps mentioned, but still couldn't get it to work. Some things I did were:

我遵循了提到的大部分步骤,但仍然无法使其正常工作。我做的一些事情是:

  • download and install google driver from android sdk manager
  • locate the device in windows device manager and update driver (pointed to the google usb driver)
  • switch usb connection from mtp to ptp
  • restarted visual studio
  • restarted computer
  • 从 android sdk 管理器下载并安装谷歌驱动程序
  • 在 Windows 设备管理器中找到设备并更新驱动程序(指向 google usb 驱动程序)
  • 将 USB 连接从 mtp 切换到 ptp
  • 重新启动视觉工作室
  • 重启电脑

Finally, what worked for me was googling the drivers for my particular android device (lg g4) and landing on this site. Once I installed the drivers I was immediately able to debug in visual studio using my device. it works whether the usb connection is mtp or ptp.

最后,对我有用的是谷歌搜索我的特定 android 设备(lg g4)的驱动程序并登陆这个站点。安装驱动程序后,我立即能够使用我的设备在 Visual Studio 中进行调试。无论 USB 连接是 mtp 还是 ptp,它都可以工作。

http://www.andromods.com

http://www.andromods.com

回答by Dumisani

In case you are using Samsung and have MyKnox installed, you cannot enable USB-Debugging until you uninstall MyKnox as stated in This Link

如果您使用的是三星并安装了 MyKnox,则必须按照此链接中的说明卸载 MyKnox,才能启用 USB 调试