How to overcome the 2 GB RAM limit on Android Visual Studio 2015 emulators

Good evening everybody!

As a devoted Xamarin dev, as soon as it got available, I installed Visual Studio 2015 Release Candidate on both my work machines, my desktop PC (with 16 GB of RAM) and my Surface Pro 3 (with “just” 4 GB of ram).

And this is where the issue raised: I tried running the new Visual Studio 2015 Android emulator, boosted by Hyper-V, on both PCs, but it relentlessly failed to launch multiple times on my Surface Pro 3, always returning this error:

Android Emulator 2048 MB error

“Visual Studio Emulator for Android: The emulator is unable to verify that the virtual machine is running: Not enough memory is available in the system to start an emulator that uses 2048 MB of startup RAM. Please close other applications and try to launch the emulator again. If closing other applications doesn’t help, please follow the instructions on this KB article: http://support.microsoft.com/kb/2911380/en-us”

And that’s what I did! I slavishly followed every single step that was suggested by that Microsoft article, and this would have theoretically led me to have a running Hyper-V Android emulator on my PC, but upon several restarts and attempts, nothing changed.

That’s where I opened the Hyper-V Manager and manually modified the settings of the Emulator “VS Emulator 5-inch KitKat (4.4) XXHDPI Phone.guido”, in order to make it need 1024 MB instead than 2048 MB. It may have worked out at first, but Visual Studio thought: “Why did he change the required RAM to 1024 MB? Hey! Let’s revert it to 2048 MB, so his poor PC won’t be capable of handling it!” (yeah, I have around 1.5 GB of free RAM, sadly, with just Visual Studio 2015 running on my SP3).

In complete despair, I started wandering in the Visual Studio installations folders on my PC, to check where the heck it was forcing the starting RAM of the emulator to be exactly 2048 MB. I encountered some files that didn’t help me at all, but at last I found the right ones, modified them and, upon trying again, my Hyper-V Android emulator was running great on my Surface Pro 3! 😀

The configuration (.cfg) files you have to modify are located here:

C:\Users\[YourUserName]\AppData\Local\Microsoft\VisualStudioEmulator\Android\Containers\Local\Devices

Just head to this URL and you will find the four little bastards:

FilesToModify

Now you will just have to open each one of them and change this line content, replacing the “2048” value with “1024”:

FROM: device.vm.ram.size=2048
TO: device.vm.ram.size=1024

While I didn’t try if the emulators were launching with lower RAM values, I suppose that it’s possible reducing the RAM size until 512 MB without incurring in major issues (and unless you are debugging a game or something as heavy). All I can say is that with 1024 MB the Hyper-V Android emulators run just as fine as they run with 2048 MB on my desktop PC.

I am leaving here a link to download a .zip file to make you able to download the four files, already patched and such: http://1drv.ms/1QjZExk

Well, this is what worked for me! 🙂 Feel free to post below here for more support, should you still have that infamous screen show up after following my guide!

Happy coding! 🙂

Why should I make my next mobile app in Xamarin? #Part1: Xamarin Performance

In this series of articles we are going to deeply analyze why it should be convenient for you (or not) developing a Mobile App using Xamarin.

One of the main doubts that is often raised by anyone I speak about Xamarin with is about the app performance.

I found an interesting in-depth review which analyses the differences between Xamarin’s Android and Java Android performance, as well as the differences between iOS native code and Xamarin’s iOS.

This is the test which involves Java (Android):

1-D89UbmzTJQ063oO7Wts_BQ

And this is the test that puts in comparison iOS native code and Xamarin’s C#:

1-yBr7maTbrt4NpTh5OjU8aA

In both case Xamarin is able to almost match the performance granted by the native platform itself, and frankly that’s quite awesome considering that Xamarin is still a young platform and has a lot of space to grow in the near future. In a few cases Xamarin even outperformed the native platform.

You can find the detailed performance comparison here: https://medium.com/@harrycheung/cross-platform-mobile-performance-testing-d0454f5cd4e9

And the github repo with the code used during the test here: https://github.com/harrycheung/Mobile-App-Performance

See you on the next post, and happy coding! 🙂

Xamarin.Forms updated to 1.3.3 :)

This evening Xamarin Forms, the best tool offered by Xamarin to build native UIs for iOS, Android and Windows Phone from a single, shared C# codebase, picked up an update which bumps its version number up to the 1.3.3 version. You can find a detailed changelog at this link:

https://www.nuget.org/packages/Xamarin.Forms/

or just below here 🙂

Release Notes

## Enhancements ##

– Deeply nested Grid performance enhanced

## Bug Fixes ##

– [Bug 21606](https://bugzilla.xamarin.com/show_bug.cgi?id=21606) – Page Title not updating when set in OnAppearing() Method the second time page is displayed. (iOS)
– [Bug 20798](https://bugzilla.xamarin.com/show_bug.cgi?id=20798) – ListView TextCell.DetailProperty only wraps on Android
– [Bug 24777](https://bugzilla.xamarin.com/show_bug.cgi?id=24777) – jobject must not be IntPtr.Zero exception when replacing Content of a Page
– [Bug 26214](https://bugzilla.xamarin.com/show_bug.cgi?id=26214) – On Android, InputTransparent=true does not work with ScrollView
– [Bug 22673](https://bugzilla.xamarin.com/show_bug.cgi?id=22673) – Initially hidden BoxView when made visible does not render (but does take up space in the UI)
– [Bug 25703](https://bugzilla.xamarin.com/show_bug.cgi?id=25703) – Webview waits to load the content until webviews on previous pages are loaded
– [Bug 26139](https://bugzilla.xamarin.com/show_bug.cgi?id=26139) – Navigation.RemovePage() still shows the back button on Android
– [Bug 26304](https://bugzilla.xamarin.com/show_bug.cgi?id=26304) – System.ArgumentNullException thrown when moving items in an ObservableCollection that is observed by a ListView
– [Bug 26064](https://bugzilla.xamarin.com/show_bug.cgi?id=26064) – ListView, ImageCell and disabled source cache and same image url leads to degraded performance
– [Bug 26121](https://bugzilla.xamarin.com/show_bug.cgi?id=26121) – Android ListView.ScrollTo doesn’t work when ListView inside TabbedPage
– [Bug 26501](https://bugzilla.xamarin.com/show_bug.cgi?id=26501) – Context Actions cause views to be hidden on iOS after re-use
– [Bug 23585](https://bugzilla.xamarin.com/show_bug.cgi?id=23585) – [Android] ListView not updated when ObservableCollection is modified

## Other Fixes ##

– [Core] CarouselPage now has more informative error when used without Children
– [Android] BoldItalic text now works as expected
– [Android] HeaderCells no longer tapable in TableView
– [Android] Fix NullReferenceException when re-using ListView on second page
– [iOS] SearchBar cancel button hides if there is nothing to clear
– [iOS] EntryCell Completed event fires twice
– [iOS] Fix potential crash with Editor inside of a ScrollView
– [iOS] Fix potential crash when ScrollView is inside of ViewCell
– [iOS] Fix issue where ContextActions could end up out of order
– [WP] Keyboard action for search does not match other platforms
– [Xaml] Text as content property now properly trims whitespace
– [Xaml] Duplicate x:Name’s throw a more informative error now
– [Xaml] Better error on Type mismatch for

Update it asap and tell us if anything improved in your everyday Forms coding! 🙂

Installing Xamarin for Visual Studio 2015 Preview

By now you probably got the blurb of last week’s Microsoft announcements:

Microsoft Takes .NET Open Source And Cross-Platform

TechCrunch – Frederic Lardinois “Unsurprisingly, the company plans to work with the Xamarin-sponsored Mono community, which already produces a cross-platform open source .NET framework based on C#. “We will announce this and then take the next few months working with the Mono community,” Somasegar told me. “We are working very closely with the Xamarin guys on this.”

With .NET turnaround, Microsoft wants to create ‘one big family’ with open-source community

GeekWire – Todd Bishop “Miguel is still the man!” said an enthusiastic S. “Soma” Somasegar, the corporate vice president in charge of Microsoft’s Developer Division. Somasegar made the comments in an interview discussing the company’s plan to open-source .NET and make it possible to use Microsoft’s developer technologies to make software for — you guessed it — Mac, Linux, Android and iOS. Microsoft is working on the initiative with the Mono community and the startup Xamarin, which de Icaza co-founded.”

Microsoft open-sources server-side .Net, launches Visual Studio 2015 preview

InfoWorld – Simon Bisson “This doesn’t mean the work on cross-platform client-side .Net will stop. “We’re going to continue partnering deeply with Xamarin,” Somasegar says. That’s borne out by the upcoming release of Visual Studio, which will make it easier to add Xamarin tools to support iOS and Android development alongside Windows apps.”

As a testament of our close collaboration with Microsoft, we shipped same-day support for Android Native C++ projects in VS 2015, as well as deep integration with Microsoft’s Hyper-V based Android Emulator.

The experience basically is that now in VS 2015 you have two new templates for Android and iOS:

New Android App

New iOS App

Launching any of those two templates will create a project that is like an introduction to the product and links to download it (similar to what the Azure templates do when you don’t have Azure SDK installed):

Install Xamarin

Now you can just click that download button, and get the new integration for 2015!

If you happened to have a previous version of Xamarin for Visual Studio installed, please keep reading as you may not have gotten the 2015 bits installed by default (it’s something we’re fixing shortly).

Ensuring 2015 support is installed (only for previous Xamarin users)

By default, Windows Installer will just update the components you have previously installed, when applying an update. Since you previously didn’t have 2015 components installed, then by default you won’t be getting them installed right now. (we’re fixing that soon-ish).

Don’t worry, you don’t have to go download anything again, here are the easy steps to ensure you turn the bits on for 2015:

1 – Go to Add/Remove programs and search for Xamarin:

Add/Remove Xamarin

2 – Click Next on the installer window and select Change on the next screen:

Change MSI

3 – Finally, make sure you check and install locally the Visual Studio 2015 feature:

Install 2015 Feature

After the installer is done applying your changes, the old “starter” templates will be gone and you’ll be greeted with a bunch of template that you’re surely familiar with already (since this section applies to existing users only ;)).

In a future post I’ll delve a bit more on how we’re integrating with Microsoft C++ Android Native projects (hint: you can just add a project reference! ;)).

Enjoy!

Just a few days far from the Italian Xamarin event!

Yeah, that’s right, we are just a few days left from the Italian Xamarin event (14/11/2014, Milan), and I couldn’t be any more excited than this! 🙂

Why so? Well, Xamarin is actually the best way for us, C# programmers, to easily port our Windows Phone apps to the Android and iOS platforms without having to learn insiders Java and Objective-C/Swift languages. Should that not look awesome enough on its own, just head to this page to be even more amazed.

Yeah, you got it right, Xamarin is offering their Indie license free to any student in the world! As long as it may look for US-only students, just compile all the fields in the page (remember using your university e-mail) to get started in the Xamarin world.

The only main lack of the Indie version is the support to Visual Studio, but you can cope with that as it’s anyway a free product, after all! 🙂

Want to easily get started coding with Xamarin? Check out the resources available following the link below here:

https://evolve.xamarin.com/

They all belong to the Xamarin event of the year, Evolve. Just watch some of them to get ready to the upcoming Italian event!

See you in Milan on the 14th of November, then! 😉

[#XAMARIN] Updating #Android emulators to work with #VisualStudio and #Xamarin

Working with Xamarin, I found myself with the following exception, building and running a demo:

Target device (emulator-5554) has an API level of 12, but this application has a minimum API level of 19 set.

The minimum API level can be changed in the project properties on the Android Manifest tab.

This error is given in our list of emulators for Android only we have available 2 virtual devices, in this case for API level 10 and 12.

image

So what we have to do is “install” or download new emulators that support in this case Api Level 19. Now it the time to search and run the Android SDK Manager.

Windows search quickly leads us to the Android SDK directory

image

And within the same we can already launch [SDK Manager.exe], which is the app who manages Android SDK resources we have installed locally. In the next image you can see I have selected resources for API Level 19 and I’ve decided to download a couple of images to work with them.

image

After a few minutes, the SDK Manager will finish the download and installation. Now you can close the Android SDK Manager and return to Visual Studio.

image

From the IDE launched the Android Emulator Manager in the option ‘ Tools / / Android/Open / Android Emulator Manager… ”

image

And we will see that we… still have only emulators for API Level 10 and 12. So that now create a new AVD with the definitions that we need. For this click on Create and for example, to create one for a Nexus 7 with the following configurations.

image

Once defined the values, we can already see the result of the process of creating the AVD.

image

It also appears in the list of AVDs

image

And you can launch it from the Android Virtual Device Manager

image

And we can see the emulator running within a few seconds

image

Note:At first glance, emulators for Android leave a lot to be desired when compared to the Windows Phone.

Now we can return to our Xamarin Android project and… when we select the device or emulator for testing, we have available the new emulator that we created in previous steps (should it now show up, a simple Visual Studio reboot will do the trick)

image

And now yes, Welcome to Xamarin Forms!