您的位置:首页 > 移动开发 > Android开发

第一个VS2015 Xaramin Android项目(终)

2017-03-18 15:22 295 查看
其实还有一个问题没解决,也拖很久了。中途公司的项目太紧导致无法学习更新。

之前的问题是这样的:项目搭建成功了,App也成功发布到虚拟机。便尝试增加控件

Xaml 设计界面如下:



但是在虚拟机运行却这样,无法显示控件:



刚开始我还以为是模拟器的问题,然后切换回Google的模拟器(很卡)结果还是这样。还尝试过使用 Android x86的模拟器,然后报错了,错误大概如下

Starting emulator for AVD 'AVD_for_Galaxy_Nexus_by_Google'
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored.
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.
CPU acceleration status: Please disable Hyper-V before using the Android Emulator. Start a command prompt as Administrator, run 'bcdedit /set hypervisorlaunchtype off', reboot.

cmd 管理员运行,

bcdedit /set hypervisorlaunchtype off


然后我尝试了 以管理员身份运行 cmd 并输入命令:bcdedit /set hypervisorlaunchtype off。再次运行 模拟器发现并不是这么简单:

参考:
使用 Intel HAXM 为 Android 模拟器加速,媲美真机

跟燕青一起学Android应用开发(四):安装Intel HAXM

提升基于英特尔® 架构的 Android* 模拟器的速度


所以.....我就放弃了~

后来在机缘巧合之下,我发现了....

1 using Android.App;
2 using Android.Widget;
3 using Android.OS;
4
5 namespace FirstAndroidTest
6 {
7     [Activity(Label = "FirstAndroidTest", MainLauncher = true, Icon = "@drawable/icon")]
8     public class MainActivity : Activity
9     {
10         protected override void OnCreate(Bundle bundle)
11         {
12             base.OnCreate(bundle);
13
14             // Set our view from the "main" layout resource
15             // SetContentView (Resource.Layout.Main);
16         }
17     }
18 }


WTF!!!! SetContentView 怎么被注释了!!! 取消这行注释,立马用那个很卡的Android 模拟器运行,发现控件终于出来了!!原来是这样!!!!

至于为什么 用那个很卡的Android模拟器,是因为之前执行了命令

bcdedit /set hypervisorlaunchtype off


想当然 应该执行

bcdedit /set hypervisorlaunchtype on


应该就可以恢复了吧?答案是错的(如下图)



因为之前 执行 off的时候是需要重启计算机方能生效,而 执行on 也应该是需要重启计算机,但是重启计算机之后可以自动on吗?

所以实行的应该是(参考:Turning hyper-v on and off):

bcdedit /set hypervisorlaunchtype auto start


重启后 Windows 的安卓模拟器回来了,第一个项目终于结束!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: