Bug 13617 - Axml files in separate project causes inflation issues
Summary: Axml files in separate project causes inflation issues
Status: RESOLVED DUPLICATE of bug 16805
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.8.x
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Radek Doulik
URL:
Depends on:
Blocks:
 
Reported: 2013-07-30 13:05 UTC by Pierce Boggan [MSFT]
Modified: 2014-07-30 11:18 UTC (History)
6 users (show)

Tags:
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:
Status:
RESOLVED DUPLICATE of bug 16805

Comment 2 Atsushi Eno 2013-08-13 01:05:20 UTC
The Fragment usage is wrong.

Java package names become lowercase. So Any Java package name for Fragment and co. in *.axml must be written in lowercase.

The issue in the report disappears once you fix the axml.

Note that the app code is still incomplete so even after fixing axml you'll see other issue.
Comment 3 klb 2013-08-13 03:03:10 UTC
I still was not able to fix the bug in my project. I know that in Java everything must be lowercase. But in Xamarin I am working with namespaces not packages. So what exactly needs to be changed in my axml file?

Here's the axml content:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/mainActivity"
    android:background="@color/white">
    <LinearLayout
        android:id="@+id/menuContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <fragment
            android:id="@+id/menuFragment"
            android:name="MobileAndroid.MenuFragment"
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="1"
            tools:layout="@layout/MenuFragment" />
        <View
            android:id="@+id/menuRight"
            android:layout_width="@dimen/menu_width_right"
            android:layout_height="match_parent" />
    </LinearLayout>
    <RelativeLayout
        android:id="@+id/fragmentController"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <LinearLayout
            android:id="@+id/fragmentContainer"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:clickable="true"
            android:orientation="vertical">
            <include
                android:id="@+id/topbar"
                layout="@layout/TopBar" />
            <View
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:background="@color/topdivider" />
            <RelativeLayout
                android:id="@+id/fragmentContent"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:minHeight="25px" />
        </LinearLayout>
        <RelativeLayout
            android:id="@+id/fragmentOverlay"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="invisible" />
    </RelativeLayout>
    <ImageView
        android:id="@+id/fragmentShadow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="fitEnd"
        android:src="@drawable/menue_schatten" />
    <MobileAndroid.MenuAnimator
        android:id="@+id/menuAnimator"
        android:layout_width="@dimen/menu_animator"
        android:layout_height="match_parent"
        android:layout_marginTop="@dimen/topbar_height" />
</RelativeLayout>


Furthermore, if I put my axml file into an Android App project, then the fragment inflation works fine. Xamarin changes the package names to lowercase. Only if I have the axml file in an Android Library project, then it does not work as expected.
Comment 4 Atsushi Eno 2013-08-13 03:53:13 UTC
We don't "change" the name. It is generated as lowercase for "Java". And anywhere in layout xml (axml is xml, the extension is only to not inject the IDEs to process arbitrary "*.xml" files in Android manner) you need to specify Java class.

The changes I made are:

android:name="MobileAndroid.MenuFragment"

    <MobileAndroid.MenuAnimator

both to lowercase package names.
Comment 5 Jonathan Pryor 2013-08-13 13:36:15 UTC
As noted in Comment #3, this XML works in an Application project, and fails only if it's in an Android Library project. If it works in an Application project, it should work from a Library project (unless there's some really compelling reason otherwise...)

The reason it works is because the MSBuild process "fixes" the .axml files to replace C# names with the corresponding Java ACW names; see the ConvertResourceCases MSBuild task.

This functionality needs to be better documented, but the behavior in Application projects has existed since March 2012 and I've mentioned this functionality in numerous forums postings, e.g.

http://forums.xamarin.com/discussion/comment/9725/#Comment_9725
Comment 6 Jonathan Pryor 2014-07-30 11:18:37 UTC

*** This bug has been marked as a duplicate of bug 16805 ***