Hockey app is a platform for mobile developers which helps in the distribution of apps for testing purpose. It provides various features like collecting the crash reports, getting user feedback, and collecting user metrics. We can think of Hockey app as an App Store for testing purposes. Hockey app supports different platforms like Android, IOS, Cordova, UWP, React Native, Unity and Xamarin. In this article, we will focus on Xamarin Android application. For the testing of Xamarin Android application, tester user just need to install the mobile app for Hockey app on their mobile device using which they will be able to see all the application they need to test and provide feedback.
Now let`s get more information about each feature.
Distribution of App for Testing:
- For distribution of an app, we just need to upload our app .apk (Android Application Package) file in Hockey app and then testers will be able to download and install the app on their mobile devices for testing through the mobile app for Hockey App.
- We can also control which user can see and install our app.
- If we have new version of our app, then tester will get a notification on their mobile device, that there is a new version available for the app. So that they can download, install and start testing.
Collect Crash Reports
- Just by integrating Hockey app SDK in our Xamarin Android application, our application can directly send the crash reports to Hockey app. No extra coding is required.
- We can get the details about the crash in our Hockey app dashboard with detailed stack trace including class name, method name and line number.
Get The User Feedback:
- User can provide the feedback for all the builds of our application through Hockey app website.
Collect The User Metrics
- It provides detailed information about how users are interacting with our application. For example the number of downloads of our app, active users, unique devices experiencing the crash and much more. For more information click here.
In this article, we will create a simple Xamarin Android application in which when the user clicks on a button, we will throw an exception which will crash the application. The exception details should get logged in Hockey app.
So let's get started:
- To get started open Visual Studio 2015 and select File Menu=> New => Project option. It will open up a project dialog box as shown below (F: 1).
- Select the Blank App (Android) project template and enter the name of the project as HockeyAppDemo and click on Ok button. After clicking on Ok button, a blank Xamarin Android application will be created.
- We need to install the following package to integrate Hockey app in our application.
Install-Package HockeySDK.Xamarin -Pre.
- To install the package, go to Tools=> NuGet Package Manager=> Package Manager Console option as shown below (F: 2).
- It will open up Package Manager Console window. Copy and paste the command from step 3 and hit enter to install the package.
- Next step is we need to get the package name for our application. We will need this, when we register our application with Hockey app. To get the package name, right click on project and select Properties option. It will open up a window. To get the Package Name select the Android Manifest option in that window as shown below (F: 3).
- Blank App (Android) project template will create a default activity for us (MainActivity.cs file with android layout Main.axml). Add the following code in Main.axml file.
The above code will add a button with simple text “Click To Crash”.
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:text="Click To Crash" />
- Add the following code in MainActivity.cs file.
Now let`s go through the code:
- using Android.App;
- using Android.Widget;
- using Android.OS;
- using System;
- using HockeyApp;
- namespace HockeyAppDemo
- [Activity(Label = "Hockey App Demo", MainLauncher = true, Icon = "@drawable/icon")]
- public class MainActivity: Activity
- protected override void OnCreate(Bundle bundle)
- CrashManager.Register(this, "<HockeyAppKey>");
- Button button = FindViewById < Button > (Resource.Id.btnClick);
- button.Click += delegate
- throw new DivideByZeroException("Divide By Zero Exception");
• When user clicks on a button, we are throwing a DivideByZeroException to crash the application.
• CrashManager.Register method will configure our application to work with Hockey app. This method requires a Hockey App key.
- To get the Hockey app key, we need to sign in for Hockey app account. (If you don`t have an account, you can sign up for free Hockey app account. After sign up, you will get an email regarding the email verification. Verify the email to proceed further).
- After login, we will see a dashboard page. We can register our application by clicking on New App button on dashboard page as shown below (F: 4).
- After clicking on New App button, we will get a popup window as shown below (F: 5).
- As shown in above image, click on manually link to proceed further.
- After clicking manually link, we will get a form as shown below (F: 6).
Select the platform as Android and enter the details as shown below (F: 7)
Enter the title and package name we got from step 6. After filling all the detail, click on save button. Hockey app will create our application. After some processing, we will get a page where our App Id is displayed as shown below (F: 8).
Copy this App Id and pass it as a parameter to CrashManager.Register method in MainActivity.cs file. (CrashManager.Register(this,”<YOUR APP ID>”))
- Now run the application using Ctrl+F5 shortcut key. Once it is deployed to emulator, click on Click to Crash button. After clicking on Click to Crash button, our application will crash because of the DivideByZeroException that we have thrown on button click event. Open the application again from the Apps screen in emulator. We will get an alert as shown below (F: 9).
Click on Send Report button to send the crash details to Hockey app. Go back to Hockey app website and refresh the page. We will be able to see that our crash report is logged in Hockey app as shown below (F: 10)
- Click on Crashes (1) link at the top as shown in above image. We will get a page which displays total number of crashes as shown below (F:11)
- Click on crash to get the crash details.
- After clicking on crash, we will get a page showing all the detail about the crash including stack trace and type of exception as shown below (F:12)
- Stack trace image is as shown below (F:13)
- Great -- we were successfully able to test our application on emulator. But for other testers to test our application, we need to upload the .apk file for our application to Hockey app.
- To create the .apk file for our application, change the Solution Configuration for our project from Debug to Release mode as shown below (F: 14)
- Now run the application using Ctrl+F5 shortcut key. It will create an .apk file in bin\Release folder of our application as shown below (F: 15).
- We need to upload the HockeyAppDemo.HockeyAppDemo-Signed.apk to Hockey app.
- Now let's go back to Hockey app website to upload our .apk file. To upload .apk file to Hockey app, select the Versions option. It will display all the versions of our application as shown below (F: 16)
- Select the 1.0 version. It will display a new page. There will be a section called as Latest Files as shown below (F:17).
- Just drag and drop HockeyAppDemo.HockeyAppDemo-Signed.apk file in Upload .apk file section as shown in above image.
- After the upload is complete, we will get a new page as shown below (F: 18) where we can enter the release notes for our application.
- After filling out the release notes, click on Next Step button.
- After clicking on Next Step button, we will get a Status page as shown below (F: 19)
As shown in above image, installation option will allow our tester user to download and install the application through Hockey App Android Application. They will also get a notification when a new version of our application is released. Using the Restricted Download option, we can define which users can install this build of our application. Keep the default settings and click on Next Step button.
- After clicking on Next Step button, we will get a Notify page as shown below (F: 20)
- Notify page allows us to notify our tester users regarding the new version of our application. Click on the Send button to proceed further. When we click on Send button, tester user will get an email regarding the release of our application including the link to download and install the app.
- After clicking on Send button, we will get a page displaying all the release details as shown below (F: 21).
- Click on Done button.
- After clicking on done button, we will be redirected to an overview screen of our app in Hockey app dashboard.
- To download the Hockey app mobile application, open rink.io/sYMAmL5 link in mobile browser. We will get a page as shown below (F: 22).
- Follow the steps shown in above image and download the Hockey app mobile application. After downloading the application, we need to sign in using Hockey app account credentials.
- After signing in, we will be able to see our application is listed in Android section as shown below (F: 23).
- Select the application. After selecting it, we will get navigated to another screen as shown below (F: 24)
- As we can see in above image, we can see all the details of our application like version number, app size, release notes etc. We can download the application using the blue floating action button at the bottom of the screen as shown in above image. Once it is downloaded, we can install and start testing the application.
- To invite other members for testing our application, go back to our Hockey app website and select Users link and click on Invite User Button and as shown below (F:25)
- After clicking on Invite User button, we will get a form as shown below (F: 26) where we need to specify the email address for our tester user, define a role (Developer, Member and Tester), tags and optional message.
- After filling in all the details, click on save button to invite the user.
- After clicking on save button, that user will get an invitation email and steps to get started with Hockey App and start testing our application.
In this article, we talked about how to integrate Hockey app in Xamarin Android application. I hope you enjoyed reading the article. Please comment to give feedback.