Thursday, June 26, 2014

From AppStudio to Android, porting AppStudio apps with a little help from Xamarin

Just a couple days ago I blogged about how you can take your AppStudio app and load it into Visual Studio, From Studio to Studio - Apps made in App Studio, opened in Visual Studio. This post is even cooler, taking it to a whole new level...

Falafel - Porting a Windows App Studio Universal App to Android Using Xamarin

Microsoft's App Studio is a fantastic tool to help you design and generate applications for Windows Phone as well as Universal Apps for both the phone and Windows. The online interface allows you to add content like RSS feeds, Facebook pages, Flicker photos and more with a few clicks, generating a complete Visual Studio solution that can immediately be launched on the phone or desktop.

Today we'll look at how we can enhance the App Studio solution’s Portable Class Library so that we can use Xamarin to add an Android version of the app.

Creating the Solution with App Studio

I want to keep things as simple as possible, so for this example, I'm using the "Empty App" template, adding a single feed from our Falafel Blogs. Here's a quick look at the project page on App Studio:

image

Retargeting the PCL for Xamarin

The Universal project includes a Data project which contains the classes for accessing data which we will want to share to the Xamarin Android project. Although this is a Portable Class Library, it's only targeted to Windows and Windows Phone 8.1. A quick change to the project properties will take care of that.

...

...

Adding the Android Project

At this point your solution should be able to build, and we can proceed to add the Android Xamarin project. Obviously you need to have Xamarin installed, and for more information on getting started be sure to take a look at their Getting Started With Android Guide.

Add a new Android project to the solution. One important thing I discovered is that if the name of your app ends with ".Android" you will have problems resolving references from the Android component libraries in Xamarin.

...

image

...

Conclusions and Considerations

I kept things simple here, using the minimal amount of code from the AppStudio.Data project to make it easy to port to Android. Obviously the more components and datasources your App Studio project uses, the more complex it might be to port everything over.

However, we have seen that Xamarin can be a true cross-platform solution, reusing C# code developed exclusively for use by Windows and with only some minor changes and a new UI, expand its reach to an entirely new platform!

Download the source code and try it for yourself: ... [GD: Click through for the link]

...

image..."

You have to admit, that's pretty darn cool. I wouldn't have ever thought that I could take an AppStudio app and with a little tweaking get it run on Android. That's like some kind of Xamarin super power or something (well the super power of portable at least... :)

No comments: