Xamarin Studio – Visual Studio Goodness on Mac

During Evolve 2016, Xamarin released Xamarin Studio (XS) for Mac as a Release Candidate. This release of XS provides more goodness like Visual Studio on Mac. Let’s see some of the features that are available in this release.

1. Dark Theme
For people like me, who work late at night, this is a boon. You can easily switch the theme and get ‘Dark Theme’ for your IDE. You can change the theme by going to
Xamarin Studio > Preferences > Environment > Visual Styles

XS-Dark-ThemeYou’ll need to restart the IDE to see the effects.

2. New Icons and Graphics
You can see lot of new improvements in terms of graphics and icons when you open a project.
XS-Icons-Graphics

3. Roslyn Support with IntelliSense / Code Completion
XS is rewritten to support Roslyn. It allows code- refactoring and better IntelliSense in IDE. This is like a ReSharper for me :)

XS-IntelliSense

4. Xamarin.Form Previewer
Xamarin.Forms Previewer will allow you to see your XAML design right next to it. It is live, so changes in XAML can reflect in UI. You can see the UI results for iOS and Android for both Phone and Tablet mode in both Portrait or Landscape mode. To see the preview, click on ‘Preview’ button on top right corner.
XS-Forms-Preview
Note: You’ll need Xamarin.Forms v2.3x Pre NuGet package to get this working.

5. Better NuGet Support
You could always add specific version of NuGet package in XS by appending ver in query string while on ‘Add Packages’ window. However, now it has became more easier as XS provides a drop-down for version selector. Small feature, but very helpful.
XS-Nuget-Versions

These are the top 5 features which I can think about when it comes to new Xamarin Studio release. There are many more and you can read about them in release documentation. I’m sure, you’ll enjoy this release.

Namaste,
Mayur Tendulkar

Advertisements

Xamarin.Forms And The Case of Failed NuGet Packages

When you create a Xamarin.Forms project, chances are there will be updates available for Xamarin.Forms libraries and associated packages. You can check for updates to NuGet packages manually or these will be restored before “build”.

The Problem:

When you create a new Xamarin.Forms app or open existing one, if you’ve fresh formatted machine with fresh VS and Xamarin installation, the build may last for longer than expected. The reason for this being, it downloads NuGet packages along with its dependencies like Android Support Packages. If in between, VS hangs or there are interruptions in network, you’ll see some errors in build like this:

XF-NUGET-02

The solution:

Well, at first you may think it is issue with Xamarin or Visual Studio or NuGet. But this all has to do with lot of NuGet packages and their dependencies download. So it all depends on machine config and network connectivity. If ever you see above errors follow the below steps:

1) Start from fresh. Close Visual Studio instances and delete everything under %appdata%local/Xamarin (e.g. C:\Users\mayur\AppData\Local\Xamarin)

2) Launch Visual Studio and open the solution. Right click each project and update NuGet packages. Android is the one which will take longer to update.

XF-NUGET-03

3) Wait till all packages are downloaded. Make sure the %appdata% folder contents all the necessary directories and files.

XF-NUGET-04

4) Build the solution. And if you still get issues about some missing some resources. Open Android SDK Manager from Tools > Android and make sure right API levels (in this case API Level 23) is installed.

XF-NUGET-05

Now run the project and it should run without any issues.

XF-NUEGT-06

Namaste,
Mayur Tendulkar

Updating Mobile Development Environment

On 20th July, Microsoft released Visual Studio 2015. This release of Visual Studio includes improvements in terms of IDE features, Language features and even changes in underlying .NET framework. Along with this, Microsoft is also releasing Windows 10 on 29th July, which will add Universal Windows Platform (UWP) development capabilities to Visual Studio. In this blog post, I’m going to cover the features that are most important for us i.e. mobile developers. Having said that, if you want to build UWP apps on RTM, hold on till July 29th, as the SDK and tooling for UWP will be released on the same day. You can find that information here.

Install Selection

You can think Visual Studio 2015 as the most complete mobile development IDE. You can build any kind of mobile applications which can run on Android, iOS and Windows devices. To setup your environment for mobile development, while installing itself, make sure you select your required tools. For example, here I’ve selected Xamarin tools to build native mobile applications. In this case, Visual Studio will install the necessary SDKs and libraries e.g. Android SDKs & NDKs with different API levels, Java SDK, etc…

VS 2015 Install

If you’re already a Xamarin developer, you may want to install Xamarin Studio, which needs to be installed separately by downloading Xamarin Installer from the site. With open sourcing of .NET and Roslyn, even Xamarin Studio is using some of its benefits. You can read more about it from Miguel’s blog.

Xamarin Integration & Project Template

Previously (VS 2013 or prior), you had to install Xamarin to get Xamarin specific project templates. With VS2015, if you select above option during install, you’ll have Xamarin project templates in File > New Project Dialog.

VS 2015 Project Templates

Note: The difference between Blank App (Native Portable) & Blank App (Xamarin.Forms Portable) is literal. That means, later one has Xamarin.Forms NuGet and integration in all projects. First one, just creates 4 separate projects without Xamarin.Forms dependencies.

When you create a Xamarin project, Visual Studio will ask you to sign into your Xamarin account to use different features according to license.

VS 2015 Xamarin

Developer (aka God) Mode

As I mentioned above, if you want to build UWP apps on RTM, you’ll need to wait till 29th July. And to enable Windows Store apps development and debugging on your machine, you’ll need to enable a ‘Developer Mode’. When you create a new project you’ll get following dialog which can take you to next dialog, where you need to select ‘Developer Mode’ and you should be able to test your apps. Do the same thing in your Windows 10 mobile device, if you want to debug apps directly on mobile.

VS 2015 - Developer Mode

VS 2015 - Developer Mode Enabled

Accessing Tools

This is not new as such to Visual Studio 2015, but I want to add it here for your reference. You can find all the tools and setting related to Xamarin and mobility under Tools menu. So, if you want to download new API Level (for example Android M Preview) or monitor your Android app’s performance on device using Android Device Monitor, you know where to look for. We’ll cover tools and features exclusive for Windows 10 in next post.

VS 2015 Tools

By the way, if you ever face any issues with Xamarin and need to contact support, Xamarin logs can help you to share more information about your issues with Support guys. Even, you can go through them and find issues/reasons. You can find them easily under Help > Xamarin

If you want to check where exactly platform SDKs are installed, you can find in Tools > Options and at two different selections

VS 2015 - SDK Location - 1

VS 2015 - SDK Location - 2

More Resources

Now, if you want to know more about Visual Studio 2015 and .NET Framework, Microsoft Channel 9 has Connect On-Demand series on it. Some of the most important videos are here

What’s new in C# 6
New Coding Experiences for C# and Visual Basic
What’s New for .NET 2015
Developing iOS and Android Apps in C# with Visual Studio
Xamarin.Forms: Leaveraging XAML to Build iOS, Android, and Windows Apps
Wearables in C#: Highlighting Apple Watch, Android Wear, and Microsoft Band
GitHub Extensions for Visual Studio

I’ll update tendulkar-uvāca series with new tools and technologies once they are released i.e. after 29th July. Till then, download the Visual Studio 2015 and enjoy the new IDE & tooling.

By the way, have I told you: You get Visual Studio 2015 Community Edition free for specific use cases and along with it, you get Xamarin Starter for free. If you’re a student, you can get more benefit through Microsoft DreamSpark program.

Namaste
Mayur Tendulkar

 

Plugin 05: Accelerometer

In our series on plugins, today we’re going to cover plugin which can help us to work with Accelerometer sensor. This sensor is responsible to detect X, Y, Z co-ordinates of the devices. Using data received from this sensor, you can build games like TempleRun, where users can collect the coins by tilting the device.

There are different APIs for different platform and their usage is different too. First, lets see how we can use this sensor in different platform and then we’ll use plugin in Xamarin.Forms application.

Being Windows Runtime API, the API and its usage is same in Windows and Windows Phone. Here, you create object of the sensor and register for ‘ReadingChanged’ event. Whenever device position is changed, it is reported through that event and UI can be updated using Dispatcher.

In case of Android, it is again similar to Windows platform. Create object of SensorManager and register for SensorChanged event.

iOS is not any different. You create object of CMMotionManager and then listen to sensor for changes.

As you can see, for three different platforms the APIs are totally different. But with Plugins for Xamarin.Forms it becomes easy. You can use DeviceMotion plugin which can work across all these platforms. And the code for same looks like:

In this series on plugin we’ve seen how particular concept can be implemented in all the three platforms and how we can use plugin to make life easier. This will be be last post in this series, but there are many plugins available which you can explore and use in your projects. Do let me know if you want to cover any specific plugin. We’ll start with a new series in couple of weeks. Till then… happy coding :)

Namaste
Mayur Tendulkar

Don’t Re-Invent the Wheel: Use Components or Plugins In Your Apps

Xamarin provides native, cross-platform mobile application development using language we all know and love – C#. However, it is still required to learn concepts of each platform. For example to send text message (SMS) in all these three platforms there are different set of APIs.

Below API is for Android, which uses SmsManager to send the text message. There is another way to do this using Intents.

image 

In case of Windows Phone, ChatMessage allows us to declare and send text message. This API is available in WinRT platform. In case of SL based apps, we need to use Launchers/Choosers.

image

In case of iOS as shown below, there is no API as such. But we use URL to launch default messaging app. In this case, we cannot set the message body, which we want to send out.

image

Life will be much simpler if there will be just one API on all these platforms which will take care of sending text messages and as I developer we don’t need to bother about on which platform it is being called. Here comes components and plugins. My friend James has written a nice blog about ‘What Exactly is a Plugin for Xamarin?’. You can read it here

In our case, we’re going to use Messaging Plugin for Xamarin and Windows which allow us to use same API to send text messages. Below code is written once in a Xamarin.Forms project which depending on platform on which code is executing, send the message using that platform’s APIs.

image

Using this plugin, it becomes easier to send text messages on Android, iOS and Windows. And this is the magic of Plugins for Xamarin.

In future posts, we’ll cover some of the best plugins and components which can help you build cross-platform mobile applications with single code-base.

I hope you’ve enjoyed this.

Namaste
Mayur Tendulkar

Revisiting Evolve – Android Player

Android is one of the mobile platforms with large user base. Every mobile developer wants to have their app on this platform. Xamarin provides great tools to build apps for Android devices using best set of tools (Xamarin.Android & Xamarin.Forms) and the language that everyone loves – C#. Having said that, it is super important to try these apps before publishing to the store, just to make sure those apps look great, work great on devices. No doubt, trying these apps on real device is highly recommended for precision and exact result. But not everyone can afford to buy all the Android devices to see how their apps works on real device. Here comes the Android emulator. Till now, Android emulators are notorious for their poor performance. People used to joke about Android emulator’s startup time that they could take a coffee breaks till it boots-up.
But these days are gone. At Evolve 2014, Xamarin has introduced a new product – Xamarin Android Player – one of the fastest and cool tool to use. It uses Intel VT-x, AMD-V technologies to make it faster. On top of it, OpenGL 2.0 helps it to deliver smooth user interface. Xamarin Android Player is available for both, Mac and Windows. You can download it from http://xamarin.com/android-player.
Once you install it, you can download available images and use them to try your app.

Screenshot-2014-10-14-12.58.19

 

Now you can create a new Android app or use your existing app and deploy it right from the Visual Studio or Xamarin Studio drop-down menu.

Screenshot-2014-10-14-13.03.08

The next image will show you more details about Android Player. Once the app is deployed on Android Player, there are tools which allows you to simulate various setting of the Android device. For example: battery, volume, screen rotation, location (GPS), etc.

Screenshot-2014-10-14-13.13.10

Just to show, how it simulates, you can try a Xamarin Android Player mini-hack from Evolve 2014 mini-hacks. You can download all of them from here: https://github.com/xamarin/mini-hacks
The app display changes as you change the battery percentage.

Screenshot-2014-10-14-13.19.22

Xamarin Android Player features:
1. Simulate, run, debug and demo apps
2. Hardware simulation: Battery, Location (GPS), Volume, Webcam (coming soon)
3. Take screenshots
4. Drag and drop APK for installation

You can read release notes for Xamarin Android Player here: http://developer.xamarin.com/releases/android/android-player/

I hope this will make your Android app development much more easier and fun.

Namaste
Mayur Tendulkar

Events! Events!! Events Everywhere!!!

I’m drafting this blog post while attending (virtually) Apple Live event about iPhone 6 and Watch. And this is a start of series of events that are happening in near future. This is your one reference guide to those events. Don’t miss them if you’re a .NET Developer, Xamarin developer or a Microsoft MVP. Smile

PUG DevCon 2014

14271_10152748338121584_4822679446261989292_n

PUG DevCon is a premier event for developers in and around Pune, India. This is going to be a 2 days, multi-track event with industry experts and speakers like Daniel, Nauzad, Raj, Guruji (Sanjay Vyas) and many more. This event is happening on 13th and 14th Sept at MCCIA, SB Road Pune. For more information visit: http://aka.ms/devcon

Xamarin EVOLVE 2014

Capture

This almost a week long event is all about cross-platform mobile and smart gear app development using Xamarin. This event also includes hands-on training and sessions by various industry experts and it is happening at Atlanta, GA on 6th Oct till 10th Oct. For More information visit: https://evolve.xamarin.com/

TechEd 2014

Capture

Microsoft India’s premier technology event – TechEd is happening from 5th till 6th Nov and this time at Lalit Ashok, Bangalore. You can find more information about this event at: http://www.india.msteched.com/ 

MVP Summit

Capture

If you’re a Microsoft MVP, you might have received MVP Summit invite –  a special invite only event for MVPs. This time it is happening from 3rd Nov till 6th Nov at Redmond. Follow the invite for more information.

And much more:

Apart from these events, there are many events in December, for example friend Kunal and Deepak are getting married. Aviraj is coming for a short India visit and I think these are big events for us. And these are very special invite only events Smile

Till then, don’t forget to register and see you at all these events. ‘Say Hi’ if you’re around (except TechEd, I’ll be at Summit).

Namaste

Mayur Tendulkar