Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

After change build resources from aapt to aapt2 and use Xamarin.Android > 8.3 resources are broken

Values of items in Resource.Designer.cs are changed ex. MvxBind = 0 changed to MvxBind = 23234334. This cause bindings didn' t work in my application and other wrong thinks happens.

Tagged:

Best Answer

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    First of all, you can not change the value, because Resource.designer.cs – This file is automatically generated and maintained by Xamarin.Android and holds the unique ID's assigned to each resource. You change one value of object will affect others.

  • MaciejJekotMaciejJekot USMember ✭✭

    @LeonLu said:
    First of all, you can not change the value, because Resource.designer.cs – This file is automatically generated and maintained by Xamarin.Android and holds the unique ID's assigned to each resource. You change one value of object will affect others.

    I never change value of this items. I know that is autogenerated. Enable generating resources by appt2 did change some const value. I saw for example that every 0 assinged for some variable in this file change value to some other. That is completely wrong. Othher example button_min_width = 0 change to button_min_width = 23232323.

    I saw in Xamarin.Android.Common.targets that after change to aapt2

    <_UseManagedResourceGenerator Condition=" '$(_AndroidUseAapt2)' == 'True' ">True</_UseManagedResourceGenerator>
    <_UseManagedResourceGenerator Condition=" '$(_UseManagedResourceGenerator)' == '' ">False</_UseManagedResourceGenerator>

    So some other resource generator is used from GenerateResourceDesigner.cs to generate Resource.Designer.cs

            // Parse out the resources from the R.java file
            CodeTypeDeclaration resources;
            if (UseManagedResourceGenerator) {
                var parser = new ManagedResourceParser () { Log = Log, JavaPlatformDirectory = javaPlatformDirectory, };
                resources = parser.Parse (ResourceDirectory, AdditionalResourceDirectories?.Select (x => x.ItemSpec), IsApplication, resource_fixup);
            } else {
                var parser = new JavaResourceParser () { Log = Log };
                resources = parser.Parse (JavaResgenInputFile, IsApplication, resource_fixup);
            }
    
  • MaciejJekotMaciejJekot USMember ✭✭
    edited June 2019

    @BrendanZagaeski said:
    I believe you are seeing Xamarin.Android GitHub issue #3049. The candidate fix for that issue is included in the latest preview versions Xamarin.Android 9.4.0.17 and higher. If by chance you have an environment where you already have or don't mind installing the side-by-side Visual Studio 2019 version 16.2 Preview 2 on Windows (or where you don't mind temporarily switching to the Preview update channel if you're using Visual Studio for Mac), then you can double-check to make sure the fix resolves all the cases you are seeing too.

    Yes I checked and this fix the problem. When full release would be available?

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai
    edited June 2019

    Excellent. Glad that resolved the issues for you project too. I'm not too sure of the timeline for the non-preview (general availability) Visual Studio 2019 version 16.2 Release, but historically, the time between the last few Visual Studio 2017 version 15.x releases was approximately 3 months, and so far the time between the Visual Studio 2019 version 16.0 and version 16.1 releases was a little under 2 months, so I suspect the time between the Visual Studio 2019 version 16.1 (released May 21) and version 16.2 releases will also fall within that 2 to 3 month range.

  • MaciejJekotMaciejJekot USMember ✭✭

    @BrendanZagaeski said:
    Excellent. Glad that resolved the issues for you project too. I'm not too sure of the timeline for the non-preview (general availability) Visual Studio 2019 version 16.2 Release, but historically, the time between the last few Visual Studio 2017 version 15.x releases was approximately 3 months, and so far the time between the Visual Studio 2019 version 16.0 and version 16.1 releases was a little under 2 months, so I suspect the time between the Visual Studio 2019 version 16.1 (released May 21) and version 16.2 releases will also fall within that 2 to 3 month range.

    Thanks for information. This is bad information for me. I' m waiting for this fix because using aapt2 and option --no-crunch in debug decrease rebuild my project from 5-6min to 0:50sec. I have a lot o png files in project and that's the reason why it's building so long.

Sign In or Register to comment.