4

The Problem:

After modifying any layout file in my Android project in Xamarin Studio, my mainlauncher (SplashActivity) throws the following exception. The exception continues to throw until I clean my project.


The Exception:

Binary XML file line #17: Error inflating class

Exception being thrown


Environment:

I am using the following tools:

Xamarin Studio: Version 5.2.1 (build 1)
Xamarin.Android: Version 4.1.0

With the following relevant settings:

Minimum Android Version: Android 4.3 (API level 16)

Computer:

Windows 7 Home Premium SP1 (x64)

Testing Device:

Samsung Galaxy S4 running Android 4.3


Relevant Code:

SplashLayout.axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:text="Loading..."
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/SPLASH_messageText" />
</LinearLayout>

SplashActivity (Trimmed to just the OnCreate):

protected override void OnCreate (Bundle bundle)
{
    base.OnCreate (bundle);
    SetContentView (Resource.Layout.SplashLayout);   // <-- this is where the exception is thrown
    MessageTextView = FindViewById<TextView> (Resource.Id.SPLASH_messageText);      // Get a reference to our message text view to update the user

    ThreadPool.QueueUserWorkItem (o => {
        InitialChecking();               // Check to make sure Google Play services are installed
    });
} // end OnCreate

My Research:

The following is a list of questions that appear related, but are not relevant to my current situation.


Additional Information:

  • When I clean the solution before debugging, the error is resolved until I modify any layout file.
  • Once this exception is thrown, it will continue to throw until I clean the solution.
  • The XML for the activity only has a text view, and it does not call to any drawable resources. Additionally, SplashLayout.axml only contains 12 lines of code.

The Question:

  • What could be causing this error, and could it happen in production?
Community
  • 1
  • 1
  • Should there be a question mark in your textAppearance attribute? – manadart Aug 20 '14 at 23:27
  • @SpiritMachine there is nothing wrong with the layout, nor the questionmark in the textAppearance attribute. There could be some strangeness with the build process somehow. OP, what version of the tools are you using? – Cheesebaron Aug 20 '14 at 23:45
  • @Cheesebaron I am using `Xamarin Studio 5.2.1 build 1`. I've edited the question to reflect that. Also, I've omitted my InitialChecking() method because I don't believe it's relevant due to where the exception is being thrown. If there's any other potentially helpful information, please tell me and I will edit my question as needed. – disappointed in SO leadership Aug 21 '14 at 04:00

1 Answers1

0

Could you please try adding this line to your axml files: xmlns:app="http://schemas.android.com/apk/res-auto"

It might sound unrelated but I had inflation problem once and it is resolved by doing so.

Oguz Ozcan
  • 1,694
  • 19
  • 26