ISE Blog

5 Do's and a Don't for Mobile Development with Xamarin

Xamarin logoLessons Learned Using Xamarin to Port Production C# .NET to Android

Recently Microsoft announced they plan to acquire Xamarin, a commercial development platform for creating cross platform mobile apps in C# .NET. This may have been the first time you heard of Xamarin, or maybe you took a second look to see what it can offer.

We've been using Xamarin to bring our eFleetSuite application to trucking fleets on Android over the last couple years. In this time we've reaped many of the benefits of the platform and have seen it mature greatly.

Are you considering Xamarin for your mobile solution? We've found 5 do's and a don't over the course of bringing our C# solution to Android.

Do: Start by throwing it all out

No, this doesn't mean you won't get to use your existing C# code. Indeed we would have gone with Java if we couldn't do that. But today's mobile platforms are a completely different paradigm than legacy desktop or mobile platforms from 10 years ago. Especially where it concerns the user interface, you need to start fresh for your app to shine.

When we took a look at our Windows C# solution we found all our business logic and SQLite db code could be reused in Xamarin with few modifications. We were then able to write a reimagined user interface using standard Android XML and the Android SDK in C# using Xamarin, and hook it right up to our logic libraries.

Do: Consider cross-platform from the beginning

Xamarin has tools for sharing simple UIs across platforms in Xamarin.Forms that you may be able to take advantage of. Even if you are developing separate UIs for each platform, you'll want to make sure you keep a clear separation of concerns, and enforce this with a good project structure. Even if you only plan to support one platform, start with a cross platform setup - it will help you keep things clean and will pay off if you ever do decide to support another platform.

Do: Believe the performance metrics

It really is just as fast - On Android your C# code is running in Mono which is running natively on the Android device, which is analogous to Java running in Dalvik. On iOS it gets compiled down ahead of time and runs natively.

We did not notice significant lag with our Classic Xamarin solution compared to Java Android apps. In fact some have found Xamarin outperforms Java Android apps.

Keep in mind Xamarin.Forms adds significant overhead compared to Xamarin using platform specific UIs, so there's a tradeoff for being able to share your UI code between platforms if you go that route.

Do: Bring your .NET and Android/iOS skills

You get the best of both worlds - Use your favorite C# .NET tools, plus make use of the entire Android and iOS SDKs just as you would in a native app. It's just like if you rewrote your Java Android app in C#.

Do: Behavior Driven Development with Calabash

Xamarin bought Calabash a while back and maintains it, along with a cloud testing platform called Xamarin Test Cloud. It's a Cucumber and Ruby based framework for behavior driven development testing. You can write feature files in plain english describing each test scenario, then use them to run black box automated tests through the user interface of your app on both Android and iOS. Almost every app development team will benefit from doing behavior driven development. More on that some other time...

Don't: Expect the same community as native Android or iOS... yet

When we first tried Xamarin in late 2013 it was relatively new, and while it had a growing community of users, it was nothing compared to the Java Android community at the time. This meant when we encountered any difficulties we had to look just a little bit harder for solutions. Luckily for paying customers Xamarin has a super responsive and helpful support team. It also didn't have an easy way to bring in the Java libraries you loved, though this appears to be easier now. Xamarin has been working hard for its users and building a significant user base now, so this is not nearly as much of a concern anymore, and with the Microsoft partnership it should only improve.

Xamarin has become one of the best cross platform mobile development solutions available today, providing native performance and code reuse to cross platform apps. What has been your experience? Let us know in the comments below, and keep checking back for more on Xamarin and other mobile development technologies.

Learn more about how ISE can help you with your mobile development solution. 

Clay Schumacher, Senior Software Engineer

Clay Schumacher, Senior Software Engineer

Clay Schumacher is a Senior Software Engineer and Practice Lead of Mobile Development at ISE. Clay lives in Normal, IL where he works from his home office and Slingshot Cowork. For the last four years he has worked to develop mobile solutions that delight our clients and end users. Clay enjoys agile/lean software development, and treats each project team as a startup bent on delivering the best app for each unique problem. He enjoys traveling and playing games with his wife and two daughters.