Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Android App Development and the Visual Studio Mobile Center

DZone's Guide to

Android App Development and the Visual Studio Mobile Center

Xamarin is now part of Visual Studio and can be used to build and monitor your Android app with the Visual Studio Mobile Center.

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

For the past week or so, I have been playing around with Xamarin and creating an Android app.

Well, I now have an app in the Google Play Store.

Before you rush and download the app, I must warn you that it doesn’t do much yet. It displays some content that is on my website and there are a few links to allow sharing of content. I have some ideas to display content from my blog and allow sharing. I also have some other ideas for apps that might actually be useful to people that are not me. If you have ideas or feature requests, do let me know.

Okay, how did I go about creating this app and getting it in the app store?

Xamarin is now part of Visual Studio, so step one is to install all the Xamarin features to Visual Studio and build an app.

Next, I wanted to monitor my app. Now I know Application Insights doesn’t support apps so what tools are out there? HockeyApp is something I had heard of but they are in the process of being replaced with Visual Studio Mobile Center.

It was relatively easy to hook up my app to Visual Studio Mobile Center. First, install the required nuget packages. Then add using statements and the following line to your MainActivity.cs file (these instructions are available on the Mobile Center).

using Microsoft.Azure.Mobile;
using Microsoft.Azure.Mobile.Analytics;
using Microsoft.Azure.Mobile.Crashes;
using Microsoft.Azure.Mobile.Distribute;
using Microsoft.Azure.Mobile.Push;

MobileCenter.Start("[Unique ID]",typeof(Analytics), typeof(Crashes), typeof(Distribute), typeof(Push));

Now you can connect the Mobile Centre to your source code (VSTS in my case) and get it to run a build for every commit.

One complexity of the build is that you need to supply a keystore file (basically a certificate to digitally sign your app). I found the best way to do this was to use Visual Studio to create the file.

In VS2017, there is an option called Archive Manager under the Tools menu. In here, click the distribute button and select Ad-hoc. In the signing identity section, you can create a keystore file. Enter a few details and a keystore file will be created in AppData\Local\Xamarin\Mono for Android\Keystore\[keystore name]\[keystore name.keystore].

Once you have added the keystore file to your build, you can enable the distribute option. Now you will get an email after every build with a link to install your app. You can also enable a build status icon like this.

Every time your app crashes, the details will be logged in the crashes section for you to explore and fix the issues.

The Analytics section allows you to explore how your app is being used. You can also add Analytics.TrackEvent(“Feature X”) to measure the usage of different features.

There are more things you can do, which I will explore more at another time, along with how to get your app into the Google Play Store.

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:
mobile ,mobile app development ,visual studio ,android

Published at DZone with permission of Simon Foster, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}