I have an app written in WPF with class library which implements some kind of a comunication protocol (mainly by using TCPClient and SSLStream classes, server certificate, etc.). Now, my client wants to have an Android app like this WPF app, where It would be nice to reuse that class library. Is this possible to do in Xamarin for Android, or I need to reimplement an application and the communication library from scratch in native Android enviroment ?
Sorry, I misread your post. Yes, of the 3 mobile platforms, Windows Phone is the most restrictive. So that's not too surprising. But the same concept applies. If you want to target windows phone too, then you'll need to make modifications.
So at a high level, Xamarin.Android is a C# wrapper around the Android SDK. You'll be using the exact same SDK as native Android developers, but you'll be using C# as your programming language instead of Java. Some of the magic in Xamarin.Android is that they ".Netify" a lot of stuff, like using C# Events instead of implementing Listeners.
So you have two options:
You can import your existing library as a portable class library. Then create an Android project that references your library. Your Android project will mainly consist of your User Interface, but all of your business logic, data layer, etc should remain in your library.
Same as #1, but you can create a Xamarin.Forms project for your UI. Xamarin.Forms is an abstraction over the Xamarin.Android, Xamarin.iOS, and Windows Phone user interfaces. You can create your UI either using C# code or through a XAML like syntax. Note, that this is not exactly the same XAML as WP or WPF, but it is very similar. When the code compiles, it will actually be Xamarin.Android (etc) underneathe the hood. This allows you to have Cross-Platform UI as well.
If you're a WPF person, I'd recommend #2 as you'll probably be more comfortable, as long as your UI is not too complicated (custom). Here are some good resources:
http://sharpmobilecode.com/nuts-bolts-of-xamarin-android/
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/
http://developer.xamarin.com/guides/android/getting_started/
Answers
Very hard to say without more information. A good place to start is by uploading your library to:
http://scan.xamarin.com/
Select your targets and it'll point out areas that are not cross platform. From there you can evaluate how to proceed.
I scanned my library, and it says:
Scan Results
99% of your code is ready for mobilization!
Xamarin analyzed the following assemblies for compatibility with Xamarin.Android: Core.dll
100%
Android
Cool! Looks like you only need to make a few minor modifications. It should have also pointed out which parts of your code is not cross platform. So you'll need to take a look at those and plan on how to either make it cross platform, or use dependency injection to inject an Android specific or WPF specific implementation into your library.
It didn't find anything. Everything is compatible. When I tried this scan for Windows Phone, it found some classes which are not available on phone, which is weird. .NET class library 100% compatible with Android but not with Windows Phone ?
Sorry, I misread your post. Yes, of the 3 mobile platforms, Windows Phone is the most restrictive. So that's not too surprising. But the same concept applies. If you want to target windows phone too, then you'll need to make modifications.
O.K. So it's (easily) possible to port my library to Android by using Xamarin for Android. I need only to do forms and menus. As I'm new in Xamarin, from where should I start to port my .net library/app to Android by using Xamarin ? In addition, would I loose something if I not use native Android approach (I'm .NET developer) ?
So at a high level, Xamarin.Android is a C# wrapper around the Android SDK. You'll be using the exact same SDK as native Android developers, but you'll be using C# as your programming language instead of Java. Some of the magic in Xamarin.Android is that they ".Netify" a lot of stuff, like using C# Events instead of implementing Listeners.
So you have two options:
You can import your existing library as a portable class library. Then create an Android project that references your library. Your Android project will mainly consist of your User Interface, but all of your business logic, data layer, etc should remain in your library.
Same as #1, but you can create a Xamarin.Forms project for your UI. Xamarin.Forms is an abstraction over the Xamarin.Android, Xamarin.iOS, and Windows Phone user interfaces. You can create your UI either using C# code or through a XAML like syntax. Note, that this is not exactly the same XAML as WP or WPF, but it is very similar. When the code compiles, it will actually be Xamarin.Android (etc) underneathe the hood. This allows you to have Cross-Platform UI as well.
If you're a WPF person, I'd recommend #2 as you'll probably be more comfortable, as long as your UI is not too complicated (custom). Here are some good resources:
http://sharpmobilecode.com/nuts-bolts-of-xamarin-android/
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/
http://developer.xamarin.com/guides/android/getting_started/
Great, thanks! No, my design is not complicated, at all. I have just two more questions:
Just open up Xamarin Studio (activate a trial) and then either create an Android Project (1st suggestion) or create a Xamarin.Forms (2nd suggestion) project. From there you can look at the tutorials and start by creating prototype or mock UIs to get your feet wet.
If you activate a Trial, you can use Visual Studio. But after your trial ends, you'll need a Business License to use Visual Studio. Alternatively you can continue to use Xamarin Studio.