Xamarin .axml .... what happened?????

GlennErlerGlennErler USMember ✭✭✭
edited November 2019 in Xamarin.Android

What happpened to .axml ? Xamarin Android project in VS 2019. If I add a new item and select android.layout it wants to create an .xml not .axml. ????? If I use the view it wont compile even if I change it to .axml. My backup machine with VS 2019 does the same. I cannot find any documentation or articles referencing any droppng the use of .axml. From what I understand .xml & .axml are the same just that .axml is what Xamrin uses for layout. I also have had VS randomly generating .xml recently that I noted in an earlier post. Any info is greatly appreciated. Am I missing something stupid.


  • GlennErlerGlennErler USMember ✭✭✭

    UPDATE: Did manage to get it to work. Changed the extension from .xml to .axml in a file explorer window. Then ADDED an existing item and it compiled and ran. If I rename in Solution Explorer it fails.

  • LandLuLandLu Member, Xamarin Team Xamurai

    axml files were used for Android layout files in previous versions of Visual Studio. But it has changed to xml in a certain version. However, I didn't remember when.
    We previously lacked infrastructure to interpret flavored versions of .xml files coming from all different types of workloads. But now xml files can be directly used in the latest version of VS.

  • GlennErlerGlennErler USMember ✭✭✭

    Thx for the reply. Any documentation you can send would be appreciated. If they did change it, I missed it and I cant find ANY mention anywhere. and.... Well the .xml it now generates wont work. This is a project that go started in VS 2017 and I am using the most recent VS 2019 Enterprise. really need to know how this fits together . Glenn

  • LandLuLandLu Member, Xamarin Team Xamurai
    edited November 2019

    I didn't find official documentation announcing this.
    But if we create a new blank Android project using the latest VS it consumes the .xml file now. I think this is to maintain the compatibility with the Android Studio.
    I also tried to build a prior project which contains the .axml files. VS will generate a corresponding .xml file for each .axml and it could be compiled successfully.
    This could be an issue of Visual Studio. You can try to raise an issue here:
    Or open a support ticket here:

  • GlennErlerGlennErler USMember ✭✭✭

    Thx for reply. I did open a request with MS. All their current documentation still references .axml files. Will post with what they reply with.

  • GrahamMcKechnieGrahamMcKechnie AUMember ✭✭✭

    I've been using xml files for months now, but only in a new project. A couple of things to check. Go to properties of the file and make sure Build Action is Android Resource and Custom Tool is MSBuild:UpdateGeneratedFiles. I think you may also have to be using aapt2 i.e. truein your csproj file.

  • GlennErlerGlennErler USMember ✭✭✭

    All the documentation for VS 2019 still references using .axml files for Xamarin android projects. Also opening an existing project does not flag a need to convert. As noted editing an existing .axml created a sister .xml file. So I would have to 2 files same name with differented extension which is where the build issue arises. If you create a Xamerin forms project it still wants to make .axml files. See what MS has to say.

  • GrahamMcKechnieGrahamMcKechnie AUMember ✭✭✭

    My project isn't a forms project, so that is probably why I don't have a problem with xml files.

    If editing a file creates a sister .xml file, then why not then delete or "exclude from project" the original axml file.

    Have you tried copying the project to another folder and tried using VS 2019 16.4.0 Preview 5?

  • GlennErlerGlennErler USMember ✭✭✭

    My project is Xamarin Android not Forms. In investigating this I noticed that Forms continued to use .axml. Xamarin Android has always used the .axml and there is no documentation of any change and the current documentation still references its use. I can work around it with some manual changes for now.

  • GrahamMcKechnieGrahamMcKechnie AUMember ✭✭✭

    If your app is Xamarin.Android then I don't understand your problem. What do you have to work around? I now don't exactly remember when xml layouts were introduced (but it has been at least a couple of months) and like you, I can't find any docs either. Maybe someone from Xamarin can step re when/where the documentation changed.

    However, the advantage far outweighs the lack of documentation because now we can use Android Studio for our constraint layouts etc and then just add the finished xml design directly to the Xamarin.Android project. No more stuffing in the Xamarin designer and copying and pasting etc. from one to the other.

  • GlennErlerGlennErler USMember ✭✭✭

    The problem was it failed to build. If you edit an .axml it creates a sister .xml file in the project and the build fails. There is no difference between an .axml and .xml other than the extension.

    I had response from the VS development team. The story is:
    1. The Xamarin Android has moved to using .xml instead of .axml.
    2. .xml and .axml can exist side x side in the same project.
    3. They do acknowledge the sister/duplicate file issue but it is not corrected yet.
    4. VS by default will now create .xml for android layout but support .axml files will not be dropped.
    5. The suggest migrating existing projects over to .xml files. I missed that memo!! LOL

    I at least I
    know what is going on now.

  • GrahamMcKechnieGrahamMcKechnie AUMember ✭✭✭

    Glad you got it sorted. I've not tried mixing xml and axml in a project.

    I made a decision to re-write my main project using AndroidX rather than just converting it. After swapping to aab in the old version, I was impressed with the reduction in size, but realised I also had a heap of near-duplicate axml files for the many dialog fragments in the project, that if consolidated would also reduce the size of the aab. So far it proving to be a successful strategy.

Sign In or Register to comment.