Search code examples
xamarinxamarin.formsxamarin.android

Migrate Xamarin.Android app to Xamarin.Forms app


I'm on the cusp of beginning a Xamarin project. I have been doing loads of research on what the best starting point would be and i have come to the conclusion that i need to learn the Android framework and begin by building a native Android app in Xamarin instead of Xamarin.Forms.

However, looking to the future i would want to be cross platform for this app. I have searched high and low on any information about what it would take to take a Xamarin.Android app and migrate it into a Xamarin.Forms app so that i can then build out the iOS app for my project.

Does anyone have any information on if this process is easy or hard to do? Can you take a Xamarin.Android app and someone migrate it to a Xamarin.Forms project? And if not would the approach be to rebuild the apps under a Xamarin.Forms project? Is there a easy approach to this?

Any info on this would be greatly appreciated.


Solution

  • With more than two years of experience with Xamarin (Native and Forms), I have never seen a tool or anything of any sort that will help you with migration but I can give you my personal opinion on this and maybe help you a little. Let's begin.

    I have been doing loads of research on what the best starting point would be and I have come to the conclusion that I need to learn the Android framework and begin by building a native Android app in Xamarin instead of Xamarin.Forms

    I would say this was a good decision Since my personal experience tells me that it is crucial for you to know either Android or iOS before you start working with Xamarin Forms otherwise there will be points in time where you will be lost af seeing the code, thinking how did you get yourself into this mess ;)

    I have searched high and low on any information about what it would take to take a Xamarin.Android app and migrate it into a Xamarin.Forms app so that I can then build out the iOS app for my project.

    There is no direct way of doing this you will have to do it the old fashioned way... Converting(Manually) Android XML to XAML is quite easy so the design won't be an issue. The C# part might be a problem as a native Android code is quite different to forms, But you can do it with ease with time.

    Note: That there will be a lot of stuff that you would want to keep in mind for eg how Xamarin.Forms works. Because when you start doing the changes you will face a lot of issues finding equivalents and stuff but it will get easier

    Does anyone have any information on if this process is easy or hard to do?

    It's not about hard or easy it's about time taking or not and trust me it takes time.

    Can you take a Xamarin.Android app and someone migrates it to a Xamarin.Forms project?

    I am a little bit confused by this part of the question but if you mean is it possible yes it is.

    My comments:

    You will need good knowledge of how Xamarin.Forms work and by that I mean you should at least go through all the Xamarin.Forms guides in Xamarin University which can be completed in a week or so with proper understanding.

    Going forward I would say use an MVVM framework for your Forms app, it will help you have a well-structured code and will keep you up to date with the industry standard.

    Also, note that MVVMCross for a beginner in MVVM is too complex, so avoid it if you have no idea what MVVM is, going with Prism or FreshMVVM would be comparatively easier.

    Don't depend too much on Xamarin.Forms NuGet's for doing certain functionalities.

    Rather write your own code using Plugins for everything is too much dependency and becomes a problem at crucial times.