Bug 24088 - android.view.InflateException during ActionBar inflation raised upon application start
Summary: android.view.InflateException during ActionBar inflation raised upon applicat...
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.18.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-10-27 20:09 UTC by Paul
Modified: 2017-08-07 20:56 UTC (History)
3 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 INVALID

Description Paul 2014-10-27 20:09:50 UTC
This happens when project is cleaned and then build and deployed to a device.


I have a custom layout for the Action bar:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="horizontal"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent"
	android:focusableInTouchMode="true"
	android:focusable="true">
	<Go.FancyTextViewLight
		android:id="@+id/textViewActionBarTitle"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:textSize="@dimen/ACTION_BAR_TITLE_TXT"
		android:textColor="@android:color/white"
		android:singleLine="true"
		android:layout_centerVertical="true"
		android:visibility="invisible" />
</RelativeLayout>

It is then set in the styles:
<style
	name="MyActionBar"
	parent="@android:style/Widget.Holo.Light.ActionBar">
	<item	name="android:background"> @drawable/buttonbg </item>
	<item	name="android:displayOptions">showCustom</item>
	<item	name="android:customNavigationLayout">@layout/actionbar_custom_view</item>
</style>

When running the application, I'm getting the exception with the reason Caused by: java.lang.ClassNotFoundException: Go.FancyTextViewLight. See stacktrace:

Stacktrace:
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown.
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00028>
[MonoDroid] at Android.Runtime.JNIEnv.CallNonvirtualObjectMethod (intptr,intptr,intptr) <0x000df>
[MonoDroid] at Android.App.Activity.get_ActionBar () <0x0010f>
[MonoDroid] at Go.MainActivity.OnCreate (Android.OS.Bundle) <0x0024b>
[MonoDroid] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x0005b>
[MonoDroid] at (wrapper dynamic-method) object.a609593c-aded-47c7-a195-20d7d3ce8c4a (intptr,intptr,intptr) <0x00043>
[MonoDroid]   --- End of managed exception stack trace ---
[MonoDroid] android.view.InflateException: Binary XML file line #28: Error inflating class com.android.internal.widget.ActionBarView
[MonoDroid] 	at android.view.LayoutInflater.createView(LayoutInflater.java:613)
[MonoDroid] 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
[MonoDroid] 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
[MonoDroid] 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
[MonoDroid] 	at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
[MonoDroid] 	at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
[MonoDroid] 	at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
[MonoDroid] 	at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3003)
[MonoDroid] 	at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3063)
[MonoDroid] 	at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1730)
[MonoDroid] 	at android.app.Activity.initActionBar(Activity.java:1892)
[MonoDroid] 	at android.app.Activity.getActionBar(Activity.java:1879)
[MonoDroid] 	at go.MainActivity.n_onCreate(Native Method)
[MonoDroid] 	at go.MainActivity.onCreate(MainActivity.java:42)
[MonoDroid] 	at android.app.Activity.performCreate(Activity.java:5163)
[MonoDroid] 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
[MonoDroid] 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
[MonoDroid] 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
[MonoDroid] 	at android.app.ActivityThread.access$600(ActivityThread.java:140)
[MonoDroid] 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
[MonoDroid] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[MonoDroid] 	at android.os.Looper.loop(Looper.java:137)
[MonoDroid] 	at android.app.ActivityThread.main(ActivityThread.java:4895)
[MonoDroid] 	at java.lang.reflect.Method.invokeNative(Native Method)
[MonoDroid] 	at java.lang.reflect.Method.invoke(Method.java:511)
[MonoDroid] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
[MonoDroid] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
[MonoDroid] 	at dalvik.system.NativeStart.main(Native Method)
[MonoDroid] Caused by: java.lang.reflect.InvocationTargetException
[MonoDroid] 	at java.lang.reflect.Constructor.constructNative(Native Method)
[MonoDroid] 	at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
[MonoDroid] 	at android.view.LayoutInflater.createView(LayoutInflater.java:587)
[MonoDroid] 	... 27 more
[MonoDroid] Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class Go.FancyTextViewLight
[MonoDroid] 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
[MonoDroid] 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
[MonoDroid] 	at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
[MonoDroid] 	at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
[MonoDroid] 	at com.android.internal.widget.ActionBarView.<init>(ActionBarView.java:262)
[MonoDroid] 	... 30 more
[MonoDroid] Caused by: java.lang.ClassNotFoundException: Go.FancyTextViewLight
[MonoDroid] 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
[MonoDroid] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
[MonoDroid] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
[MonoDroid] 	at android.view.LayoutInflater.createView(LayoutInflater.java:552)
[MonoDroid] 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
[MonoDroid] 	... 34 more



This can be fixed if I change the case of namespace Go.FancyTextViewLight to go.FancyTextViewLight. But it breaks again after subsequent cleanup. Then changing it from go.FancyTextViewLight to Go.FancyTextViewLight does the trick again.


=== Xamarin Studio ===

Version 5.5.2 (build 0)
Installation UUID: a6a75a2e-663d-4f28-9bee-ec7d1889267d
Runtime:
	Microsoft .NET 4.0.30319.18444
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.18.0 (Enterprise Edition)
Android SDK: C:\Users\pnovodon\AppData\Local\Android\android-sdk
	Supported Android versions:
		4.1 (API level 16)
		4.2 (API level 17)
		4.3 (API level 18)
		4.4 (API level 19)
		4.5 (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_31
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)

=== Build Information ===

Release ID: 505020000
Git revision: a5887be38215a6cdd3f349e102ef82a1c4f950a4
Build date: 2014-10-14 12:21:34-04
Xamarin addins: 069ddd29bb70a42238142eee9bac21a5e4b2f9f9

=== Operating System ===

Windows 6.1.7601.65536 (64-bit)
Comment 1 Rajneesh Kumar 2014-10-28 05:09:04 UTC
I have checked this issue and able to reproduce the reported behavior
"android.view.InflateException during ActionBar inflation raised upon application start". To reproduce this issue I have followed the information/code provided in bug description.

Steps I followed:

1. Create an android application in XS
2. Opem Main.axml and go to source view and paste following code:
     <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:focusableInTouchMode="true"
    android:focusable="true">
    <Go.FancyTextViewLight
        android:id="@+id/textViewActionBarTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:singleLine="true"
        android:layout_centerVertical="true"
        android:visibility="invisible" />
</RelativeLayout>
                
3. Comment the following line of code in MainActivity.cs
  //Button button = FindViewById<Button> (Resource.Id.myButton);
 //button.Click += delegate {
 //button.Text = string.Format ("{0} clicks!", count++);
 //};
4. Build the application, it will build successfully
5. Deploy it on emulator you will get the following exception

Exception: https://gist.github.com/sunil360/7d42136026983b8246b4

Screencast: http://www.screencast.com/t/mKzd25axUNpg

Please confirm that It is same issue that you have reported and also confirm
whether I have followed correct steps to reproduce this issue or not?

Please let me know if I am missing anything.

Environment Info: 

=== Xamarin Studio ===

Version 5.5.2 (build 0)
Installation UUID: a7e29e93-6348-4126-9ebc-b2777c96a552
Runtime:
	Microsoft .NET 4.0.30319.18408
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.18.0 (Business Edition)
Android SDK: E:\android-sdk
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode)

=== Build Information ===

Release ID: 505020000
Git revision: a5887be38215a6cdd3f349e102ef82a1c4f950a4
Build date: 2014-10-14 12:21:34-04
Xamarin addins: 069ddd29bb70a42238142eee9bac21a5e4b2f9f9

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 2 Paul 2014-10-28 19:07:13 UTC
Sorry, you also need the actual class:
namespace Go
{

class FancyTextViewLight : Android.Widget.TextView
	{

		public FancyTextViewLight(IntPtr ptr, JniHandleOwnership handle) : base(ptr, handle)
		{
			
		}

		public FancyTextViewLight(Context context) : this(context, null)
		{
		}

		public FancyTextViewLight(Context context, IAttributeSet attrs) : this(context, attrs, 0)
		{
		}

		public FancyTextViewLight(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs)
		{
			if(this.IsInEditMode)
				return;

			this.PaintFlags |= Android.Graphics.PaintFlags.SubpixelText;
		}
	}
}
Comment 3 Jon Douglas [MSFT] 2017-08-07 20:56:21 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Android. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.