Xamarin Forms beginners challenges

Xamarin Forms beginners challenges

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 issueYour 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

Follow me on social media and stay updated

6- Debugging Sucks !!!

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.

Follow me on social media and stay updated

7 comments

  1. Eric

    Reply

    For number 5 isn’t a WYSIWYG designer extremely difficult? Xamarin Forms doesn’t provide its own controls with a similar look across all the platforms but it uses the native controls for each platform under the covers. And each rendered native control can have different dimension than the same thing on a different platform. Also when a new android OS comes the looks some controls can look completely different. Taking that in mind how would you create a designer that will show you exactly what your app will look like across all the platforms.? The supported platform list also keeps growing which also adds to the difficulty. I can certainly see why no one wants to take on the daunting task of creating a designer or if they do why it will take a long time to get right.

    • Reply

      Yeah, I mentioned the native look issue in number 9 too.
      What you just mention is surely a great difficulty faced when thinking about building a designer.
      But I’ve read a discussion between .Net developers out there and they seamed to agree they needed a designer on XAML platforms only as beginners but
      they don’t really need it as proffesionals, (Check it here) and that a XAML designer for Xamarin.Forms is not really needed.
      But there is this new feature actually in preview in Xamarin.Forms 3.0 Called Live Reload, which lets you see your UI Changes live as you edit XAML,
      I think this feature compensates the absence of a designer.

  2. Sergio

    Reply

    Excellent article! Newbie to xamarin with a strong .Net background. By not having a designer tool where you can drop your controls on a form, isn’t it really a step back on development? I understand thousands of developers use Xamarin but dealing with learning XAML apart from the new development concepts just make things a lot harder and a huge learning curve. Do you know if a designer is in the Xamarin roadmap or any third party already providing such tool?
    Find it weird the lack of one built in designer tool on such a new platform and having to hard code the UI by hand.

    • Reply

      I dont think there is a plan for a Xamarin designer at least, not to my knowledge, and also there is no third party who made this tool available. But, you have the XAML previewer, which allows you to see as you type in XAML code, recently, in XAmarin.Froms 3.0 the hot reload functionality was made available and it will surely speed up your development experience. If you are not used to XAML but you have CSS skills, you could as well style your xamarin forms applications using css. And in this article they explain why a visualstudio’s xaml designer does not work for Xamarin Forms XAML.

  3. Reply

    Very interesting and knowledgeable article! I really enjoyed it. Keep sharing such valuable stuff! If anybody want to design and develop the Mobile app in XAMARIN or any other latest technologies like hybrid, ios development, android mobile development, react native, etc, then free to call us at 950-111-3517 (India) and +1 (888)-670-0009 (toll-free for CA and US)

  4. Turan5000

    Reply

    Lets not forget the challenge about the publishing xamarin to IPAD or Iphone.. I have lost lots sleep and still losing it

    • Damien Doumer

      Reply

      Hi, what challenge is that about ? you mean publishing your app to the stores ?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.