Federico Navarrete
Federico Navarrete

Reputation: 3274

What is the difference between XML and AXML in Xamarin.Android Apps?

Since VS2019, I have noticed that every new project has regular XML as its resources like native Android Studio applications, but previously (2015 or 2017) it created AXML files.

Internally, the files looked exactly the same. However, I have recently started to get linker errors (as reported in .NET for Android issues #3376 and #3387), which made me wonder if they have anything to do with the change from AXML to XML.

Are there specific differences between these formats?

Upvotes: 9

Views: 6590

Answers (3)

Jon Douglas
Jon Douglas

Reputation: 13176

.axml is nothing more than an extension hack that was used to render Android Layout Files i.e. Android flavored .xml files inside Visual Studio. It literally meant .axml (Android XML).

We previously lacked infrastructure to interpret flavored versions of .xml files coming from all different types of workloads. However in 16.2 and 8.2 respectfully (Visual Studio and Visual Studio for mac), you can use .xml seamlessly in your application and be provided a layout editor, rich intellisense, and more.

If you don't require a layout editor, you have been able to use .xml since the first release of MonoDroid as .axml is processed the same way as .xml at the end of the day.

Upvotes: 15

Ivan I
Ivan I

Reputation: 9990

First of all, Link all assemblies is prone to crashing and while those crashes can be fixed with some level of effort and knowledge, exactly because it causes more trouble than what it helps it isn't recommended option by Xamarin. So those are not 'bugs', those crashes are expected behavior.

Second, that comment on github that you linked doesn't tell there is any problem with axml files. It says that your axml file requires some library to be present and that it cannot be determined by the compiler which removes it and causes crashes.

Basically it has nothing to do with the question in your title.

Upvotes: 0

Miiite
Miiite

Reputation: 1557

First, the linker does not do anything with your layout files. So .axml or .xml, it just won't touch it or parse it. The linker only work with the classes represented by the layout files, not the layout files themselves.

Now, regarding the ".axml" versus ".xml" I believe the ".axml" extension is just a legacy thing from MonoDroid. The only goal of that specific extension was probably to identify android layout files, from regular xml files, without any advanced logic (it's only a supposition).

Long story short, if you're facing issues in your project regarding the linker, it's probably not related to your extension choice for layout files. You should keep whatever Visual Studio defines as the default.

Upvotes: 3

Related Questions