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
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.
- Xamarin - Binary XML file line #1: Error inflating class - The error was caused by using a color state-list as a background. I don't even define a background.
- Binary XML file line #17: Error inflating class - This error was due to using the
android:attr/textAppearanceListItemSmall
attribute while targeting an API level that did not support it (>14). My minimum Android Version is API level 16. - InflateException: Binary XML file line #1: Error inflating class - The problem was caused by a resource decoding a large bitmap that caused the VM to run out of memory. I am not loading any images, or drawables.
- Binary XML file line #9: Error inflating class fragment - I am not using fragments
- android.view.InflateException: Binary XML file line #6: Error inflating class - *OP was using depreciated
AbsoluteLayout
, I am using aLinearLayout
- EditText tag causes Error inflating class - Error was caused by
android:scrollY="10dp"
, which is not in my layout.
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?