Updated Installing Xamarin Cycle 9 side by side with Android Studio 2.3

Android Studio 2.3 released on 1 March.   I recently created a guide to install Xamarin side by side with Android Studio 2.2.3 here.

 

The steps illustrated remain the same.   The only difference is, the Android Studio 2.3 zip  file (without sdk and installer) can be located here.    If 2.23 was previously installed, migrate the 2.2.3 settings on first run of Android Studio 2.3.   This will copy across the shared SDK location with the Xamarin installation.

 

Android Studio 2.3

 

Happy Xamarin Development!

FacebookTwitterGoogle+LinkedIn

MVP Award 2017

I returned home from the Cape Town Xamarin User’s group last night to find that I have just become a Microsoft MVP for the first time!!!

 

 

 

I am so honored to be receiving this award!!  Thank you to all that made this possible.      It is really really amazing to know that all the years of work that went into assisting and contributing to the Xamarin and Microsoft community, globally and in South Africa has been appreciated!

 

Thank you once again!   And here’s to more community fun and enjoyment!!

 

FacebookTwitterGoogle+LinkedIn

CTXUG Monthly Meetup 1 March 2017

Tonight was a very fun evening at CTXUG (Cape Town Xamarin User’s Group).      The two topics presented were Telerik UI for Xamarin and Lottie.       The User Group was held at the MLab office at the waterfront which is a great place to have events!

 

Event URL:  https://www.meetup.com/Cape-Town-Xamarin-Users-Group/events/237781504/

 

Telerik UI

 

“Telerik® UI for Xamarin by Progress is a collection of UI controls and functionalities that complement the default controls found in the platform. The controls offer many non-trivial scenarios out of the box, helping developers to implement polished UI with native-quality performance in their apps faster, shortening time to market. Telerik UI for Xamarin includes Xamarin.iOS wrappers, Xamarin.Android wrappers and Xamarin.Forms controls.”

 

I did the first talk this time on Telerik UI for Xamarin.      It was great showing off what the component set could do, and everyone seemed inspired and impressed with what Telerik UI for Xamarin offers.

 

I do hope the free Telerik license recipients will be presenting the cool stuff they build soon at CTXUG!!!  🙂

 

Thank you to Telerik for all the giveaways!!

 

Speaker:   Allan Pead

 

The slides for this can be found on github:    http://bit.ly/2mGtt61

 

More details on Telerik UI for Xamarin can be found here:  http://www.telerik.com/campaigns/xamarin-ui/telerik-ui-for-xamarin

 

Photos

 

Telerik UI For Xamarin Talk

 

Telerik Swag

 

Lottie

Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile!

For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand.”

 

Chris van Wyk  (from Xamarin University) gave an amazing talk on the amazing animation framework Lottie.   Everyone (including myself) was really, really impressed what Lottie can do.

 

Speaker:   Chris van Wyk

 

More information about Lottie:  https://github.com/martijn00/LottieXamarin

 

Photos

 

Lottie Talk

 

 

I hope to see everyone at CTXUG soon!  <Update> The next User Group meetup is on the 29th of March.   The topic will be Visual Studio 2017!!

 

FacebookTwitterGoogle+LinkedIn

Android Things GPIO Callbacks

Following the blog post to get you up and running with Android Things, Visual Studio and Xamarin.  http://explorationspace.co.za/2017/02/26/using-xamarin-and-visual-studio-with-android-things/

 

Android Things has GPIO callbacks which are triggered on certain trigger events.    This is great for event handling.    I’ve added a sample to Xamarin bindings which illustrates this by means of a Grove PIR (Passive InfraRed) sensor much like what’s in your home alarm system.   If we use that in conjunction with a buzzer, you have a primitive alarm system.

 

The source can be found here:   https://github.com/apead/Xamarin-Android-Things

 

Intel Edison with PIR and Buzzer

 

 

Gpio callbacks are classes implemented inheriting from the abstract class Gpio Callback.    This call back is triggered on certain trigger types.   This are set on the gpio pin with the settriggertype method.

  • EDGE_NONE: No interrupt events. This is the default value.
  • EDGE_RISING: Interrupt on a transition from low to high
  • EDGE_FALLING: Interrupt on a transition from high to low
  • EDGE_BOTH: Interrupt on all state transitions

 

 public class AlarmCallback : Com.Google.Android.Things.Pio.GpioCallback
 {
 public Gpio BuzzerPin { get; set; }

 public override bool OnGpioEdge(Gpio p0)
 {
 if (p0.Value)
 {
 if (!BuzzerPin.Value)
 {
 BuzzerPin.Value = true;
 Thread.Sleep(1000);
 BuzzerPin.Value = false;
 }
 }

 return true;
 }

 public override void OnGpioError(Gpio p0, int p1)
 {
 Log.Info("Alarmcallback", "Error");
 }
 }

 

The class has two methods to override.   OnGpioEdge and OnGpioError.     The OnGpioEdge method is called on a trigger event.     The OnGpioError is called on an error.

 

This class is registered on the actual input gpio pin.


_callback = new AlarmCallback {BuzzerPin = _buzzerGpio};

_alarm1Gpio.RegisterGpioCallback(_callback);

 

Happy Android Things development with Xamarin!

 

FacebookTwitterGoogle+LinkedIn

Using Xamarin and Visual Studio with Android Things

Android Things is Google’s new IOT Android based platform.    In essence it’s a slightly altered version of Android which can run on Iot type devices such as the Intel Edison and the Raspberry Pi3.

 

“Android Things lets you build professional, mass-market products on a trusted platform, without previous knowledge of embedded system design.”

 

Personally I’m not yet too impressed with Android Things.   It is still very new and very raw and is lacking a lot of what you’d expect from an Iot platform.   However, having finally a standard Android implementation officially from Google running on these devices has to be a good thing.    The platform should just get better from here.

 

 

 

Running in Visual Studio using Xamarin

 

Of course being Android, Android Things works with Xamarin too.     Using Xamarin will also be a benefit for all those awesome cross platform benefits it offers, like sharing your Iot code with your backend services, Android, Ios, Windows Phone, Windows 10, OSX, XBox and whatever other devices you’d like to be supporting in your solution.

 

Getting the devices to appear in Visual Studio is exactly as you’d expect.    The devices will use the standard Android Debugging Bridge (ADB).      Plugging in an Intel Edison via USB will be reflected as “Unknown Iot_Edison”.    You can obviously also use the network debugging features of ADB.   eg.   adb connect <ip address>   The device will then also be detected in Visual Studio.   A Raspberry Pi will appear as “Unknown iot_rpi3”.

 

Using Xamarin is very simple.    All we need to do is bind to the Android Things API Jar to be able to make use of all the features provided by the Android Things SDK.   At this moment in time there isn’t an official release Nuget package from Xamarin to do this.   It is however very simple to do this yourself.     In this sample (and I’ve shared the code on GitHub) I’m binding to the new Dev Preview 2 API for Android Things (androidthings-0.2-devpreview.jar).    Once the binding project is referenced from your Android Things project, everything will work as expected.   Just of course with the benefit of using C# and not Java!

 

I’ve created some samples based on the Standard Android Things Samples

 

Samples:   https://github.com/apead/Xamarin-Android-Things

Blink Led

No Iot sample and demo is complete without a blinking LED.   This sample is a conversion of the Android Things sample.

 

 

Simple UI

This sample is a simple illustration of using a UI on an Android Things device.   It also illustrates GPIO pins and how to set the high/low values of the pins.

 

Simple UI Android Things Sample

 

 

 

Learning Resources:

 

SDK Samples:  https://developer.android.com/things/sdk/samples.html

How to install Android Things on your Device:   https://developer.android.com/things/preview/index.html

A great article on the basics of electronics and hardware:  https://riggaroo.co.za/android-things-hardware-basics/

 

Happy Android Things Development with Xamarin!

FacebookTwitterGoogle+LinkedIn

Installing Xamarin Cycle 9 side by side with Android Studio

You may need to run Android Studio and Xamarin side by side from time to time.   This may be needed if you are an Android developer experimenting with Xamarin or maybe you are migrating an Android application to Xamarin.   I run the two side by side often especially when I am binding native libraries for Xamarin.        I put together a guide to make the new Xamarin Cycle 9 release and Android Studio 2.2.3 run together without any pain and also without wasting disk space with multiple copies of Android Sdks.    I also find it’s much cleaner to install everything manually without the installers.     This guide is specifically aimed for Windows and Visual Studio 2015+ users.

 

Installing Xamarin

Install Java JDK 1.8  x64  (Use the latest update of this available)http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

 

Install the Android NDK

 

The NDK is a zip file.  Extract this to a location that’s easily accessible:   C:\AndroidSDK\android-ndk-r13b-windows-x86_64

 

Install the Android SDK

 

The simplest and cleanest is to install the command line version of the SDK

Android SDK Command line installation: https://dl.google.com/android/repository/tools_r25.2.3-windows.zip

This is just a zip file not requiring any installation.  Extract the contents to a location that’s easily accessible.  Eg.  C:\AndroidSDK\tools_r25.2.3-windows

 

Install the required SDK Tools and APIs

From command line execute <Android SDK>\tools\android  This will open the SDK manager.

 

Install Android SDK tools 25.2.5

Install Android SDK platform tools 25.0.3

Install Android Build tools 25.0.2

 

 

Install API 25 SDK Platform   (and whichever other APIs you require)

Install “Sources for Android SDK” for API 25.    Xamarin does not require this, but Android Studio will later request it be installed.    This will simplify the later setup if done now.

 

 

Install Google Repository

Install Google Play Services

Install Android Support Repository

 

 

Install Xamarin for Visual Studio 4.3.   If you installed Xamarin with Visual Studio 2015, you have it already.    To upgrade to Cycle 9 use the Updater Channel within Visual Studio.      Alternatively if you don’t have it, you can manually install it:  https://store.xamarin.com/account/my/subscription/downloads.   Download the individual installation package per platform (and not the universal installer).  At the time of writing this there isn’t a direct link to cycle 9, so download cycle 8 and update it.

 

 

Set up the SDK paths within Visual Studio.   There is a setting for both the path to the NDK and SDK previously installed.  The location of the Java SDK should be set here too.    Visual Studio will need to be restarted for this to take effect.

 

Note:   If Xamarin was previously installed via the Visual Studio or the Xamarin Universal Installer.  There will be another Android SDK installed.    This is most likely:   C:\Users\<user>\AppData\Local\Xamarin\Universal\AndroidSDK.     If the steps above were followed, this previous path can be safely removed.       This folder can be used to share the SDK with Android Studio, however personally I don’t think it’s a great location for doing that.

 

The Xamarin Cycle 9 installation is complete and should now work with the new SDK location.

 

Installing Android Studio 2.2.3

 

Download the Android Studio zip file (without installer and SDK):   https://developer.android.com/studio/index.html

 

Extract the Android Studio Zip to any desired location eg:  D:\AndroidStudio\android-studio-ide-145.3537739-windows

 

On first run, Android studio will start the wizard to set itself up (and download the SDK).   Skip the wizard.

 

 

Choose “Settings” from the Start screen.

 

 

Specify the path previously used for the Android SDK. eg:  C:\AndroidSDK\tools_r25.2.3-windows

 

Everything needed should already be in place, so Android Studio will accept the SDK without any problems.

 

 

Android Studio should now work fine with shared SDK with Xamarin.

 

Happy Xamarin and Android Coding!

 

FacebookTwitterGoogle+LinkedIn

Xamarin.Forms ContextActions, Binding and Mvvm Code Sample

How to bind a ContextAction in a Xamarin Forms ListView to a View Model?  This is a question I was asked recently.   I created a simple code sample for this, so thought I’d share it with everyone.

 

Below is a link to the sample on GitHub.    It includes an example of how to do it in code and in XAML.

 

 

https://github.com/apead/FormsMvvmContextActionSample

 

Happy Xamarin.Forms Coding!

FacebookTwitterGoogle+LinkedIn

Xamarin and .NET automated builds and continuous integration (CTXUG)

Come join us for a very practical session on automating your Xamarin builds and setting up a continuous integration environment.

Leave here with skills to be able to use any CI tooling with Xamarin.

I am the speaker for this event.

 

Agenda 

1) Introduction to Continuous Integration

2) How does Xamarin build stuff behind the scenes?

Fundamentals of MSBUILD

Xamarin and MS Build

iOS build agent for Visual Studio

iOS and Android Packaging

3)  Setting up a continuous build server

The  code repository

Automating the build

4)  Test Cloud

 

We will also have a first look at Visual Studio Mobile Center.

 

Hope to see you there!

 

Update

 

The content is available here:  https://github.com/apead/XUGSABuildAutomation

FacebookTwitterGoogle+LinkedIn

Xamarin and .NET automated builds and continuous integration (GXUGSA)

Come join us for a very practical session on automating your Xamarin builds and setting up a continuous integration environment.

Leave here with skills to be able to use any CI tooling with Xamarin.

I am the speaker for this event.

 

Agenda 

1) Introduction to Continuous Integration

2) How does Xamarin build stuff behind the scenes?

Fundamentals of MSBUILD

Xamarin and MS Build

iOS build agent for Visual Studio

iOS and Android Packaging

3)  Setting up a continuous build server

The  code repository

Automating the build

 

Hope to see you there!

 

Update

The content is available here:  https://github.com/apead/XUGSABuildAutomation

FacebookTwitterGoogle+LinkedIn