Continuous integration/continuous delivery for your Xamarin app with VSTS and HockeyApp – Part Android
In addition to my previous posts about this subject, I got some reactions that it was iOS only! And I can’t deny that. If you haven’t noticed by now, I’m an iOS guy and I’m proud of it! Nevertheless, one of the main advantages of Xamarin is that you can swing both ways (and even more than both!). So for most projects I try to at least support iOS and Android. Therefore, let me be complete and also explain how to setup your building and deployment pipeline for Android as well!
Spoiler alert; it isn’t much different from iOS.
Then what is the difference? #
There are a few subtle differences throughout the whole process. Let’s start by looking at the build definition. While the concept remains the same, the actual steps in you definition differ a little bit.
If you’ve read my other blog posts, you’ll notice two things: the flow is the same, but the actual build step for our App is a different one than for iOS.
You can identify it by the little Apple - and in this screen little Android - icon. All it means is that you have some other stuff you can configure. For iOS you need to configure stuff like provisioning profiles, etc. that is iOS specific. You don’t need that for Android, so you won’t see it back here. Something that you do configure here is the JDK version you want to use for compiling your app. Although Ive never had to configure anything about it.
Versioning #
Another this that is a bit different is the way you version your app. Although the means to do it stay the same.
Here we also use the build step available to us in VSTS. But for our Android app we need to do a regex search in the AndroidManifest.xml file. Again, Richard Woollcott did a far better post about that, so check that out for the details on this.
Also you’ll notice that the signing of our binary is a separate step for our Android app.
Also no rocket science here. If you’ve built an Android app before you know how to do this manually. Just make sure you check in your keystore file in your repository and reference to it. Then put your password in and the rest will happen automagically!
This enables you to send your apk file over to HockeyApp or even the Google Play store! Apple apps cannot be send directly to the App Store from 3rd party software, but with Android you actually can! The build task isn’t in VSTS by default, but you can download it from the Marketplace here.
Test Cloud #
Of course your Android app has to be tested as well, which can be done with the awesome Test Cloud! Actually this doesn’t have much differences with the iOS one apart from some configuration.
Make sure you have the Xamarin.Android build step in there (you can copy it from the build definition above!) and configure your Test Cloud build task a bit different. In this case you have to send over your apk file instead of the ipa, and your probably want some other devices in here as well.
Wrapping up #
Actually that is all that’s different! Well probably I’ve forgotten about some bits and pieces, but as you can take away from above is that it is all in the details. Replacing .ipa with .apk gets you a long way already.
Actually one more thing! Although your app feels like one app on different platforms, HockeyApp sees your same app on different platforms as two different apps. So if you want to distribute through there, make sure you create a separate app for that and connect the new App ID to your Android build definitions.
Good luck! If you have any questions, don’t hesitate to contact me!
Also if you all want to see this work live, my guest lecture on this will be on Xamarin University next Tuesday. You can sign up for it here (University account required).