Bug 12713 - Resource.Layout.filename is returning the wrong layout file
Summary: Resource.Layout.filename is returning the wrong layout file
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2013-06-16 23:10 UTC by Has
Modified: 2013-12-05 18:34 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Has 2013-06-16 23:10:14 UTC
I have a MonoDroid application project (let's call it mainApp). This references app.Screen project, which is a MFA library project. Initially, my activities were in the mainApp project. Everything was working fine. I needed to put some Activities (and resource, drawables, etc) in the app.Screen project. I have moved all the resources I need to the app.Screen project. It builds fine and in my activities (which are sitting in app.screens) I can access Resource.Layout.filename and even Layout.Id.name.

However, when I run the application, in SetContentView(Resource.Layout.filename) I get the wrong layout file . This causes FindById<Button>() to return null obviously because it does not have these buttons in this layout file.

I found that same Layout file has different Id in my MFA library project than what is in the mainApp project like this:

// In the mainApp project
public partial class Layout
    // aapt resource value: 0x7f030001
    public const int DeliveryScreenLayout = 2130903041;

    // aapt resource value: 0x7f03000a
    public const int splash_screen_layout = 2130903050;

    private Layout()

// in app.screen library project
public partial class Layout

    // aapt resource value: 0x7f030000
    public static int has_hello_layout = 2130903040;

    // aapt resource value: 0x7f030001
    public static int splash_screen_layout = 2130903041;

    private Layout()
I am using VS 2010 with MFA 4.0 and my projects are targeting Android 4.0. I have tried Clean & Build, Removing /Bin and /Obj folder, with no luck. Any help would be much appreciated.
Comment 2 Jonathan Pryor 2013-06-17 14:52:56 UTC
Which Xamarin.Android version is this? The Library project's Resource file is incorrect, in that there should be a Layout static constructor which calls Android.Runtime.ResourceIdManager.UpdateIdValues().

This might be Bug #11697, which was fixed in Xamarin.Android 4.6.4.

If you're using a release after 4.6.4, please attach a project demonstrating the problem.
Comment 3 Has 2013-06-18 22:03:12 UTC
Thanks for the response, I am using 4.6.0009 or something like this. I will upgrade later on and test with 4.6.4 and let you know. Thanks
Comment 4 PJ 2013-11-19 17:04:30 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 5 PJ 2013-12-05 18:34:34 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.