Bug 35245 - Xamarin.Designer.DesignerException: You must specifiy a valid layout reference. The layout ID @layout/toolbar is not valid.
Summary: Xamarin.Designer.DesignerException: You must specifiy a valid layout referenc...
Alias: None
Product: Android
Classification: Xamarin
Component: Designer ()
Version: 5.1
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jérémie Laval
Depends on:
Reported: 2015-10-26 00:34 UTC by Prashant Cholachagudda
Modified: 2017-06-28 15:11 UTC (History)
2 users (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 Prashant Cholachagudda 2015-10-26 00:34:06 UTC
When we add 

<include android:id="@+id/toolbar" layout="@layout/toolbar"/>

in a layout.axml file, the designer can no longer show the layout in content view, and gives the error "The layout could not be loaded: You must specify a valid layout reference. The layout ID @layout/toolbar is not valid.

The toolbar is saved in the file Resources/layout/toolbar.axml and contains:

<?xml version="1.0" encoding="UTF-8" ?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:popupTheme="@android:style/ThemeOverlay.Material.Light" />

This is only a designer issue. If we compile the app and run it on a device, the toolbar is shown correctly. If we insert the toolbar tag directly into the layout file instead of using the <include> tag, the designer works correctly, but that limits the ability to re-use it on multiple layouts.

You can find the sample code at - https://blog.xamarin.com/android-tips-hello-material-design-v7-appcompat/

# Stacktrace 

ERROR [2015-10-15 12:19:46Z]: Session initialization failed
Xamarin.Designer.DesignerException: Exception of type 'Xamarin.Designer.DesignerException' was thrown.
   at Xamarin.AndroidDesigner.JavaProcessConnection.GetResponse(BinaryMessage message, Int32 timeout)
   at Xamarin.AndroidDesigner.JavaProcessConnection.SendMessage(BinaryMessage message)
   at Xamarin.AndroidDesigner.AndroidRenderSession.InitSession(DesignerSessionParams refreshConfiguration, String& errorMessage)

# Version information

=== Xamarin Studio ===

Version 5.9.7 (build 22)
Installation UUID: e8c608a8-7812-483f-bc4e-52c93740d711
Microsoft .NET 4.0.30319.42000
GTK+ 2.24.22 (MS-Windows theme)
GTK# 2.12.26

=== Xamarin.Android ===

Version: 5.1.7 (Enterprise Edition)
Android SDK: C:\Program Files (x86)\Android\android-sdk
Supported Android versions:
4.0.3 (API level 15)
4.1 (API level 16)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
Java SDK: C:\Program Files\Java\jdk1.8.0_60
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.1
Location: C:\Program Files\Xamarin Android Player\DeviceManager.exe

=== Build Information ===

Release ID: 509070022
Git revision: 6bd1f169df44ca96addf8a035316c535a4fa46fa
Build date: 2015-09-30 10:13:51-04
Xamarin addins: 1c3e5c0859bdfec0ecd481a57ad6c03bc22f5536

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 1 Adam Hartley [MSFT] 2017-06-28 15:11:53 UTC
Unfortunately, we’re unable to reproduce this report. If this issue is still occurring for you, please reopen this issue and attach a reproduction to the bug by starting with a clean Xamarin.Android project adding just the code necessary to demonstrate the issue.