android - Xamarin.Android 项目无法在适用于 Android 的 Visual Studio 模拟器中部署

标签 android xamarin android-emulator xamarin.forms visual-studio-emulator

我在 Windows 10 build 10586 TH1 上使用 visual studio 2015 update 1。

我还使用 Xamarin 版本 4.0.1.96。

我创建了一个空白的 Xamarin.Forms 应用。 它可以毫无问题地部署到 Windows Phone 模拟器。但无法部署到 Android 模拟器。

当我启动 android 项目时,Android 模拟器成功启动 但 visual studio 在这一步卡住。

我试了很多android模拟器配置文件都无法解决问题。

此问题仅存在于模拟器和成功部署在物理 android 设备上的项目。

我对 Xamarin.Android 项目有同样的问题。

这是输出窗口中的所有文本:

  • 1>开始部署 4.5"KitKat (4.4) HDPI 电话 ...
  • 1>正在启动模拟器 4.5"KitKat (4.4) HDPI Phone ...
  • 1>验证模拟器参数...
  • 1>正在确定模拟器是否已经在运行...
  • 1>准备虚拟机...
  • 1>正在启动模拟器...
  • 1>模拟器启动成功

预先感谢您的帮助。

最佳答案

我在模拟器启动查找时遇到了同样的问题,但 Visual Studio 在构建/部署时挂起。终于从here弄明白了.

Visual Studio gets stuck trying to deploy the app to the emulator or the emulator does not appear as a debug target in other IDEs

If the emulator is running, but it does not appear to be connected to ADB (Android Debug Bridge) or it does not appear in Android tools that make use of ADB (for example, Android Studio or Eclipse), you may need to adjust where the emulator looks for ADB. The emulator uses a registry key to identify the base location of your Android SDK, and looks for the \platform-tools\adb.exe file under that directory. To modify the Android SDK path used by the emulator:

  • Open Registry Editor by selecting Run from the Start buttons context menu, typing regedit in the dialog box, and choosing OK.
  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools in the folder tree on the left.
  • Modify the Path registry variable to match the path to your Android SDK. Restart the emulator and you should now be able to see the emulator connected to ADB and associated Android tools.

我的注册表中的值设置为“C:\Program Files (x86)\Android\android_sdk”(或类似名称)。将其更新为“C:\Users\{USERNAME}\AppData\Local\Xamarin\MonoForAndroid\AndroidSDK”为我解决了这个问题。 (我还没有担心如何让所有用户都能使用它。)

关于android - Xamarin.Android 项目无法在适用于 Android 的 Visual Studio 模拟器中部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35863809/

相关文章:

android - 谷歌地图有商业许可证吗?

android - 当 View 的父布局是 ConstraintLayout 时,我想要 View cover Button,但这不是我期望的结果

c# - xamarin.ios mp3 在屏幕关闭时停止播放

从快照启动时出现 Android Emulator Out of memory 错误

java - 不幸的是,Android 应用程序已停止并可在 Android 设备上运行

android - JSOUP Android 问题

android - 横向模式的 setOnItemClickListener

android - 使用 xamarin.forms 通过蓝牙打印机打印数据

c# - Xamarin 绑定(bind)从列表中动态创建的按钮

android - (使用 Android Studio)AVD 在我的应用程序启动期间崩溃