Microsoft HockeyApp with Xamarin Android

Microsoft HockeyApp with Xamarin Android

hockeyAndroid1

Short introduction

My recent article was connected with Microsoft Azure Application Insights that helps developer to track app crashes and general performance. In this article I would like to show you similar tool – Microsoft HockeyApp.

With this tool you as a developer are able to distribute early versions of your apps for testing, track app performance and collect feedback from involved testers.

What do I need to start?

1) Visual Studio 2015 Community (for free) or higher

2) Xamarin Android subscription (you can test it for free here)

3) Android Phone or Xamarin Android Player Emulator (download here)

4) HockeyApp free trial account (available under this link)

Let’s start

1) CREATE HOCKEYAPP FREE TRIAL ACCOUNT AND ACTIVATE IT THROUGH E-MAIL:

hockeyAndroid2

2) AGTER REGISTRATION AND CONFIRMATION YOU SHOULD HAVE ACCES TO DASHBOARD:

hockeyAndroid3

3) NOW OPEN VISUAL STUDIO 2015 AND CREATE NEW XAMARIN ANDROID PROJECT:

hockeyAndroid4

4) NOW ITS TIME TO ADD NEW XAMARIN COMPONENT TO YOUR APP CALLED “HOCKEYAPP FOR ANDROID”:

Right click on the “Components” folder and select “Get more components”

Type “Hockey app for Android” in search box

Add component to your app

Sign in with your Xmarin account if needed

hockeyAndroid5

hockeyAndroid6

hockeyAndroid7

Reference should be added and component also:

hockeyAndroid8

5) NOW LETS GET BACK TO THE HOCKEYAPP WEB DASHBOARD:

Click green button named “Start integration”

Type information about the app that you have created in Visual Studio – note that “Package name” should be exactly like in your app manifest file

Click “Next step”

You app should appear in the dashboard

hockeyAndroid9

hockeyAndroid10

hockeyAndroid11

Click on the created app. You should have access to App ID:

hockeyAndroid12

6) BACK TO VISUAL STUDIO. NOW WE MUST CONFIGURE HOCKEYAPP SETTING WITHIN OUR MOBILE APP:

Open app manifest and add this line with activity as a child element of <application> tag:

 <activity android:name="net.hockeyapp.android.UpdateActivity">
 </activity>

 

Add permissions:

uses-permission android:name="android.permission.INTERNET"
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"

 

Now we must add some code to the “MainActivity” class (please note the comments):

public class MainActivity : Activity  
   {  
       public const string HOCKEYAPP_APPID = "a5d6d3d6b35a487aa051c8c6f4707f54";  
       protected override void OnCreate(Bundle bundle)  
       {  
           base.OnCreate(bundle);  
  
           SetContentView(Resource.Layout.Main);  
           configureHockeyApp();  
       }  
  
       private void configureHockeyApp()  
       {  
           // Register the crash manager before Initializing the trace writer  
           HockeyApp.CrashManager.Register(this, HOCKEYAPP_APPID);  
  
  
           // Initialize the Trace Writer  
           HockeyApp.TraceWriter.Initialize();  
  
  
           // Wire up Unhandled Expcetion handler from Android  
           AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) =&gt;  
           {  
               // Use the trace writer to log exceptions so HockeyApp finds them  
               HockeyApp.TraceWriter.WriteTrace(args.Exception);  
               args.Handled = true;  
           };  
  
           // Wire up the .NET Unhandled Exception handler  
           AppDomain.CurrentDomain.UnhandledException +=  
               (sender, args) =&gt; HockeyApp.TraceWriter.WriteTrace(args.ExceptionObject);  
  
           // Wire up the unobserved task exception handler  
           TaskScheduler.UnobservedTaskException +=  
               (sender, args) =&gt; HockeyApp.TraceWriter.WriteTrace(args.Exception);  
       }  
   }  

 

7) LAUNCH YOUR APPLICATION ON THE EMULATOR OR PHONE:

hockeyAndroid13

8) NOW YOU CAN UPLOAD YOU .APK FILE THROUGH HOCKEYAPP DASHBOARD:

hockeyAndroid14

You can send this version to your testers, collect crashes data and analyse your app performance from there:

hockeyAndroid15

 Sum up

In this article I tried to show how to simply integrate your Xamarin Android app with Microsoft HockeyApp platform. Of course I showed only the basic functionality. For more information you should visit official HockeyApp website:
hockeyapp.net/features

Advertisements