Bug 39867 - Using 'include' tag in AXML files causes designer error
Summary: Using 'include' tag in AXML files causes designer error
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Android
Classification: Xamarin
Component: Designer ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Jérémie Laval
URL:
Depends on:
Blocks:
 
Reported: 2016-03-23 15:09 UTC by Ryan Alford
Modified: 2017-06-29 07:25 UTC (History)
2 users (show)

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


Attachments
Screenshot of error (104.14 KB, image/png)
2016-03-23 15:09 UTC, Ryan Alford
Details


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:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Ryan Alford 2016-03-23 15:09:10 UTC
Created attachment 15498 [details]
Screenshot of error

I have been running into an issue for a while now, where I include a layout in another layout, and the Xamarin Studio Android designer throws exceptions about the layout being invalid. This only seems to be an issue when the <include> tag is a direct descendent of a parent LinearLayout. I have other views that have a parent CoordinatorLayout that do not give the issue.

This is a pretty standard example. I am including a Support V7 Toolbar in other layouts. Here is the toolbar xml..

-- main_layout.xml --

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />


This layout is failing...

-- activity_procedure.axml --

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <include
        layout="@layout/main_toolbar" />
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical"
        android:fillViewport="true">
        <TextView
            android:text="Text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/ProcedureBody"
            android:layout_marginLeft="@dimen/standard_left_margin"
            android:layout_marginRight="@dimen/standard_left_margin"
            android:paddingTop="@dimen/workorder_procedure_top_bottom_margin"
            android:paddingBottom="@dimen/workorder_procedure_top_bottom_margin" />
    </ScrollView>
</LinearLayout>


However, this layout does not give the error...

-- activity_labor_entry_list.axml --

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/root">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <include
            layout="@layout/main_toolbar" />
        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:overScrollFooter="@android:color/transparent"
            android:id="@+id/LogEntryListView" />
    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>

The error that I get is the following...

-- 
Bridge [resources.resolve] Couldn't resolve resource @string/app_nameBridge [resources.resolve] Couldn't resolve resource @layout/main_toolbarandroid.view.InflateException: You must specifiy a valid layout reference. The layout ID @layout/main_toolbar is not valid.
	at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:90)
	at android.view.LayoutInflater.parseInclude(LayoutInflater.java:858)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:802)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
	at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
	at mono.android.DesignerSession.load(DesignerSession.java:170)
	at mono.android.DesignerSession.processMessage(DesignerSession.java:640)
	at mono.android.MessageListener.executeMessage(MessageListener.java:87)
	at mono.android.MessageListener$Runner.run(MessageListener.java:44)
	at java.lang.Thread.run(Thread.java:745)
mono.android.DesignerException: You must specifiy a valid layout reference. The layout ID @layout/main_toolbar is not valid.
	at mono.android.DesignerSession.load(DesignerSession.java:186)
	at mono.android.DesignerSession.processMessage(DesignerSession.java:640)
	at mono.android.MessageListener.executeMessage(MessageListener.java:87)
	at mono.android.MessageListener$Runner.run(MessageListener.java:44)
	at java.lang.Thread.run(Thread.java:745)


Here is my Xamarin information..

========================================================================
========================================================================
========================================================================
=== Xamarin Studio ===

Version 5.10.3 (build 26)
Installation UUID: f79f018c-2fe8-422f-88c9-47931b42d14e
Runtime:
	Mono 4.2.3 (explicit/832de4b)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402030004

=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: 9.4.2.27 (Enterprise Edition)
Hash: 58ba2bc
Branch: master
Build date: 2016-03-03 09:05:19-0500

=== Xamarin.Android ===

Version: 6.0.2.1 (Enterprise Edition)
Android SDK: /Users/jra2249/Sandbox/AndroidSDK/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Version: 0.6.2
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 510030026
Git revision: ac9b7fcba9ee92ac30c8eb90f20c2228ce033efa
Build date: 2016-03-01 18:02:09-05
Xamarin addins: 633fde3bf405e3c402a51980976c431c204cf4f6
Build lane: monodevelop-lion-cycle6-c6sr2

=== Operating System ===

Mac OS X 10.10.5
Darwin frssmac02 14.5.0 Darwin Kernel Version 14.5.0
    Mon Jan 11 18:48:35 PST 2016
    root:xnu-2782.50.2~1/RELEASE_X86_64 x86_64


========================================================================
========================================================================
========================================================================
Comment 1 Ryan Alford 2016-03-23 15:10:30 UTC
Just wanted to add that the layout works fine. When the app is ran, the toolbar shows up correctly. So this seems to just be a designer issue.
Comment 2 Ryan Alford 2016-06-10 12:05:27 UTC
Wanted to post to this again. I've updated to XS 6 and this is still an issue. With the many enhancements made to the Android designer, it still can't properly display "include" layouts?
Comment 3 Ryan Alford 2016-06-10 12:06:37 UTC
I do get a different error message now...

java.lang.ClassCastException: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:757)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:728)
	at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
	at android.view.LayoutInflater.parseInclude(LayoutInflater.java:783)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:746)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:728)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:373)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:391)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:337)
	at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
	at mono.android.DesignerSession.load(DesignerSession.java:170)
	at mono.android.DesignerSession.processMessage(DesignerSession.java:640)
	at mono.android.MessageListener.executeMessage(MessageListener.java:87)
	at mono.android.MessageListener$Runner.run(MessageListener.java:44)
	at java.lang.Thread.run(Thread.java:745)
mono.android.DesignerException: Views of type com.android.layoutlib.bridge.MockView can't contain child views
	at mono.android.DesignerSession.load(DesignerSession.java:186)
	at mono.android.DesignerSession.processMessage(DesignerSession.java:640)
	at mono.android.MessageListener.executeMessage(MessageListener.java:87)
	at mono.android.MessageListener$Runner.run(MessageListener.java:44)
	at java.lang.Thread.run(Thread.java:745)
Comment 4 Prashant [MSFT] 2017-06-29 07:25:44 UTC
@Ryan

Thank you for taking the time to submit the bug. We are unable to reproduce this issue. Please attach a reproduction to the bug by starting with a clean Xamarin.Android project and adding just the code necessary to demonstrate the issue.