4

Xamarin ,

Xamarin , Tags: beginners, challenges, Xamarin.Forms



Hello Friends, I remember when I first heard about Xamarin.Forms. As a .Net developer, discovering a tool which will let you leverage your .Net skills to build cross platform applictions. I literally had water in my mouth 🤤. As an excited beginner, I went directly to Google and learned everything I could about Xamarin.Forms. Then Bam !!! I was ready to try out this awesome framework. But… yeah, there is a but. I had a hard time figuring out how to run the IDE’s sample project template. I had a lot of error messages and it wasn’t really as easy as I expected. Since by then I didn’t have many resources about Xamarin.Forms, it took me long to run my fist Xamarin.Forms app.

What I mean to say here is, I was once a Xamarin.Forms beginner and faced the challenges which many other Xamarin.Forms beginners face. Just by looking at a few questions or posts. From stack overflow, the Xamarin Forum or Reddit, you find people who just got started with Xamarin.Forms complain. And some of these Xamarin.Forms beginners, go on insulting and pouring out their rage on this framework. I understand their frustrations, since they might have spent weeks without even succeeding in running Visual studio’ s Xamarin.Forms project templates. But I don’t think these Xamarin.Forms beginners challenges is a reason to insult this awesome framework. I mean, it’s not perfect, but it serves its purpose and does a great job at the performance level. Above all, It makes developers use C# and .Net everywhere.

Many Xamarin.Forms Beginners get discouraged by the problems they face at an early stage. For example check how this guy absolutely quits Xamarin.Forms development After a few trials. So, Let’s take a deep look at these challenges and possible solutions to overcome them.

What we will be doing

We will go through 10 challenges which xamarin.forms begginers mimght face and possible solutions to these challenges. I made this list based on my experience and many posts and questions asked by xamarin.forms beginners on sites like Stack overflow, Reddit or the Xamarin forum. The points which I’ll make in this post may be subject to criticism, so I’ll like to have your opinions, thanks.

Let’s Dive into these xamarin forms beginners challenges

1 – I get a thousand error messages at my first build

This is one of the most annoying challenge a Xamarin Forms beginner can face. You launch your IDE, Select Xamarin.Forms project template, but you can’t run it immediately. This is either due to nuget packages which are not restored or packages which need to be updated. If you face this issue, the first thing to do is to restore all your nuget packages for the solution and update if need be. Check this article on how to restore nuget packages in visual studio.

2- I can’t compile and run my app!!!

In some cases, even after restoring packages you may have difficulties compiling and running your app. This is usually because of platform specific packages needed to run the app. For example, after restoring nuget packages, you may face errors like missing package Xamarin.Android.Support.Design or any other Xamarin.Forms support package issue. Your IDE may complain about Missing References to Dependencies or Packages which are actually PRESENT in your solution Or, after running you app, it emidiately closes. All of these issues and a lot more will hinder compilation. Resolving such issue is not always easy, and covering how to deal with each of them requires me to write a new post so instead, here is a link to solutions to these commonly faced problems.

3- What the hell is this XAML stuff ? Why does this XAML seem so different from .Net XAML

When you are a Xamarin.Forms beginner, and new to .Net development too, you can get very confused in the beginning. XAML is a markup language used to build user interfaces in .Net apps. You have the choice to build user interfaces either with XAML or with C# code and you may ask your self if you should use XAML the answer is YES you should. Using XAML allows you to better separate UI code from code logic, and is a better choice when you will implement MVVM. Another difficulty comes when you are from WPF, UWP … background you think the XAML you are used to is another form of XAML, with different names for controls. to overcome this, You should check Xamarin.Forms documentation, and Check this article about XAML Standards.

4- Where are these Ghost exceptions coming from ? How do I understand them ?

Another annoying issue is, running your app to later have it throw what I call Ghost Exceptions Exceptions thrown with only a minimum information about their occurrence. For example, only the name of the exception is given, and but no additional information is given. This type of exception occures mostly when there is an error in your XAML code, and since you cannot place break points in XAML, it is a little bit difficult to figure out what the exception is. The best way I overcome this is by launching the app on a different platform, and depending on how the exception is thrown on each platform, you can get enough information about it. I mostly find out that such exceptions are thrown when ever I’m careless in my XAML code.

5- Where is the designer ?

When you are from a mobile development background like Android or UWP, you are used to have a designer where you drag and drop views. But in Xamarin.Forms there is no such designer at least not yet and not to my knowledge. This can seem weird at first and even frustrating, check this post from a Xamarin.Forms beginner who poured out his rage after such frustration. Check this article which will tell you more about this.

This Xamarin Forms application to help you manage your expenses and income was built entirely with Xamarin Forms and ReactiveUI. You can download and use it or play with it for free on Android and Windows 10 (Universal Windows Platform). You can get it on Playstore, or on the Microsoft Store.

Like this: Like Loading...

6- Debugging Sucks !!!

Follow me on social media and stay updated

This is one of the most common complaints. You want to debug your app, and you find out that it is some times not as easy as what you are used to. Exceptions occur all the time and where in your code the exception occured is not always obvious. Yes, this is sometimes true, but Xamarin.Forms has become a lot better with time, so nowadays it is even easier to debug. My preferred debugging approaches are; When the unhandled exception occurs I read the Inner Exceptions from these exceptions. This almost always give me a clue about the cause and where the exception occurred. Or when an unknown exception fires, with no details on platforms like android, I try to run the app on windows to fire this exception, since in my opinion, windows platform describes better the exceptions which occur. Of course when I use Xamarin.Forms.

7- Must I compile and run my code every time I want to see my app’s UI ?

The answer to this is clear and simple. No, you mustn’t. There are several tools available for you to visualize your XAML layout while you code. Some of these codes include the XAML previewer on Visual Studio and Gorilla Player. These tools will make app development in Xamarin.Forms a lot more faster.

8- MVVM

When you are new to .Net platform, you may wonder what is MVVM. Because you must have heard about it several times especially if you develop mobile or desktop apps. Though MVVM Architectural Design Pattern is not a must, you should invest time learning it and master a Xamarin.Forms MVVM Framework. Which will make your code more maintainable.And you will have a better time while building Xamarin.Forms apps since it will avoid you countless troubles related to poorly designed code.

9- Why does my app not look totally native as it should be ?

In deed, Xamarin.Forms is a Native cross platform UI framework. But when you take a look at the controls which it provides for each platform, they are not always identical to those you see on the respective platforms. In my Opinion, the order in which most of Xamarin.Forms controls look native on each platform is UWP > Android > iOS. But this does not mean you cannot give this native aspect to your controls. This could be done very easily using custom renderers as described in this documentation.

10- Understanding the Xamarin.Forms Philosophy

This is one of the things I find in common with most of the beginners who ask questions. On sites like Reddit or Stackoverflow. They don’t fully the Xamarin.Forms approach to cross platform development. Xamarin.Forms is not a Black Box Tool which you will code everything in C# and Tada!!! is is converted into native Android, iOS … native app. Instead, you should see it as a only a UI Framework. Which provides you a set of controls you could use in one project. And these controls have their own implementation on each platform. The Xamarin.Forms way is very particular, and I think understanding it will help facilitate its use by any new developer. This article deeply explains the XAmarin.Forms way.

Conclusion

With these, I think I went through most of xamarin Forms beginners challenges. One may find that following these 10 points makes development with Xamarin.Forms easier. You could also check this post to learn how to call a custom native popup dialog in xamarin.forms.

If you liked this post, or it was useful to you, please 👍 like it, share it on twitter, facebook or other social media… in case you want to get updated on any new useful post, follow me on twitter and like my page on facebook.

Like this: Like Loading...

Follow me on social media and stay updated