Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, February 8, 2013 8:00 AM
Hi,
My code is
Main.axml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/MyButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Hello" />
<fragement
android:name="test.fragement.example.Fragment1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
and Activity1.cs
public class Activity1 : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
}
}
and Fragment1.cs
namespace test.fragement.example
{
public class Fragment1 : Fragment
{
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup grp, Bundle bundle)
{
base.OnCreateView(inflater, grp, bundle);
View vw = inflater.Inflate(Resource.Layout.frag1, grp, true);
return vw;
}
}
}
This code is throwing an error for me. Stack trace
Android.Views.InflateException: Binary XML file line #1: Error inflating class fragement
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00024] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:616
at Android.App.Activity.SetContentView (int) [0x0006b] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/monodroid/src/Mono.Android/platforms/android-10/src/generated/Android.App.Activity.cs:3119
at test.fragement.example.Activity1.OnCreate (Android.OS.Bundle) [0x00009] in c:\Mono\test.fragement.example\test.fragement.example\Activity1.cs:22
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00010] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/monodroid/src/Mono.Android/platforms/android-10/src/generated/Android.App.Activity.cs:1490
at (wrapper dynamic-method) object.4b6fec41-0b84-4cbb-85e3-f821d04add6e (intptr,intptr,intptr) <IL 0x00017, 0x00043>
End of managed exception stack trace
android.view.InflateException: Binary XML file line #1: Error inflating class fragement
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
at android.app.Activity.setContentView(Activity.java:1657)
at test.fragement.example.Activity1.n_onCreate(Native Method)
at test.fragement.example.Activity1.onCreate(Activity1.java:28)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: android.view.fragement in loader dalvik.system.PathClassLoader[/data/app/test.fragement.example-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.view.LayoutInflater.createView(LayoutInflater.java:471)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
... 21 more
How to solve this ?
All replies (28)
Sunday, April 7, 2013 2:54 PM âś…Answered
What a numpty. I have put the namespace in the path for the classname now and of course it works. Sorry for wasting everyone's time
Monday, February 11, 2013 2:02 PM
This error normally means that your fragment name that you're setting as a class variable in your AXML file is incorrect, what do you have set for the fragment name?
Wednesday, April 3, 2013 9:46 PM
I get the same error and it is not the fragment name setting the class variable as described by chrisntr. To try to find out where I was going wrong, I created the HoneyCombFragments sample as an IceCreamSandwich app and copied the code across from the sample into my newly created files and I still get the error. The only differences in the code are the namespace and the number of using statements in the files. Any ideas what I may be doing that is wrong?
Thursday, April 4, 2013 1:48 AM
@Johnacharya: The problem is in your Main.axml
; you mis-spelled "fragment":
<fragement android:name="test.fragement.example.Fragment1" android:layout_width="fill_parent" android:layout_height="wrap_content" />
This results in the exception:
android.view.InflateException: Binary XML file line #1: Error inflating class fragement
Notice it's "fragement". (Which coincidentally is your namespace name, so this appears to be a common spelling error.)
Please update your Main.axml
file to use <fragment/>
, not <fragement/>
.
Thursday, April 4, 2013 1:51 AM
@CurleyWurley:
The only differences in the code are the namespace
That would do it. The //fragment/@android:name
attribute needs to be a fully qualified class name, either the C# name or the Android Callable Wrapper name (case sensitive). Change the namespace, and the corresponding //fragment/@android:name
value must be updated as well.
Sunday, April 7, 2013 1:33 PM
I'm still getting the error after I have recreated the solution.
Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment UnitsFragment: make sure class name exists, is public, and has an empty constructor that is public
Default layout main:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
class="UnitsFragment"
android:id="@+id/unitsfragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
Large Layout Main:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
class="UnitsFragment"
android:id="@+id/unitsfragment"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/details"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent" />
</LinearLayout>
UnitsFrament.cs:
using System;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Views;
using Android.Widget;
namespace chalkhouse
{
public class UnitsFragment : ListFragment
{
//The code here is the same as the fragments walkthrough from Xamarin
}
}
Sunday, April 7, 2013 1:34 PM
Lost some of the code in the previous post!
Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment UnitsFragment: make sure class name exists, is public, and has an empty constructor that is public
Default layout main:
Large Layout Main:
using System;
using Android.App; using Android.Content; using Android.OS; using Android.Views; using Android.Widget;
namespace chalkhouse { public class UnitsFragment : ListFragment { //The code here is the same as the fragments walkthrough from the xamarin site } }
Sunday, April 7, 2013 1:35 PM
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layoutwidth="fillparent" android:layoutheight="fillparent" fragment class="UnitsFragment" android:id="@+id/unitsfragment" android:layoutwidth="fillparent" android:layoutheight="fillparent" LinearLayout
Sunday, April 7, 2013 2:52 PM
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layoutwidth="fillparent" android:layoutheight="fillparent" fragment class="UnitsFragment" android:id="@+id/unitsfragment" android:layoutwidth="fillparent" android:layoutheight="fillparent" LinearLayout
Tuesday, April 9, 2013 3:11 AM
@CurleyWurley: Perhaps you should review the Markdown documentation, in particular the Code block usage?
The problem appears to be that you're not using a fully qualified type name:
class="UnitsFragment"
The class name must be fully qualified:
class="chalkhouse.UnitsFragment"
Tuesday, October 14, 2014 11:49 AM
<LinearLayout
android:id="@+id/detail_other"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal" >
<RelativeLayout
android:id="@+id/wrapper_detail_other"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical"
android:id="@+id/other_name_image" >
<ImageView
android:id="@+id/other_image"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:src="@drawable/ballempty" />
<TextView
android:id="@+id/other_name"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_below="@+id/other_image"
android:editable="false"
android:focusable="false"
android:gravity="center_horizontal"
android:text="Amandeep Goyal" />
</LinearLayout>
<LinearLayout
android:id="@+id/detail_own_left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/other_name_image"
android:orientation="vertical" >
<EditText
android:id="@+id/other_wheretomeet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:focusable="false"
android:hint="Where To Meet" />
<EditText
android:id="@+id/other_whattobeer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:focusable="false"
android:hint="Dress Code" />
<EditText
android:id="@+id/other_whentomeet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:focusable="false"
android:hint="When To Meet" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/detail_own"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<RelativeLayout
android:id="@+id/wrapper_detail_own"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:id="@+id/own_name_image" >
<ImageView
android:id="@+id/own_image"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:src="@drawable/ballempty" />
<TextView
android:id="@+id/own_name"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_below="@+id/own_image"
android:editable="false"
android:focusable="false"
android:gravity="center_horizontal"
android:text="Aman" />
<EditText
android:id="@+id/own_wheretomeet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Where To Meet" />
<EditText
android:id="@+id/own_whattobeer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Dress Code" />
<EditText
android:id="@+id/own_whentomeet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="When To Meet"
android:editable="false" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
i am using above layout and i am getting same error (Layout inflation error).Please let me know where i am wrong.
Monday, January 26, 2015 5:22 PM
There are other reasons for getting such an error- not just in the misspelling of a widget name or tool. I got that error when I used a drawable file (containing a color I created using xml code) as my textcolor. It appears errors generated can cover a truckload of reasons and not just one reason.
Thursday, March 12, 2015 6:13 PM
im also getting this error
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown.
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00047>
[MonoDroid] at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00084] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:896
[MonoDroid] at Android.App.Activity.SetContentView (int) [0x00070] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.App.Activity.cs:3831
[MonoDroid] at Music.MainActivity.OnCreate (Android.OS.Bundle) [0x00211] in c:\Users\Exoskeletor\Documents\Projects\Music\Music\MainActivity.cs:132
[MonoDroid] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.App.Activity.cs:1944
[MonoDroid] at (wrapper dynamic-method) object.7354a995-f9d8-457d-8806-4fc45cf85429 (intptr,intptr,intptr) <IL 0x00017, 0x0001f>
[MonoDroid] End of managed exception stack trace
[MonoDroid] **android.view.InflateException: Binary XML file line #1: Error inflating class fragment**
[MonoDroid] at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
[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 android.view.LayoutInflater.inflate(LayoutInflater.java:352)
[MonoDroid] at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
[MonoDroid] at android.app.Activity.setContentView(Activity.java:1867)
[MonoDroid] at music.MainActivity.n_onCreate(Native Method)
[MonoDroid] at music.MainActivity.onCreate(MainActivity.java:50)
[MonoDroid] at android.app.Activity.performCreate(Activity.java:5008)
[MonoDroid] at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
[MonoDroid] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
[MonoDroid] at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
[MonoDroid] at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3512)
[MonoDroid] at android.app.ActivityThread.access$700(ActivityThread.java:130)
[MonoDroid] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
[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:4745)
[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:786)
[MonoDroid] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[MonoDroid] at dalvik.system.NativeStart.main(Native Method)
[MonoDroid] **Caused by: java.lang.IllegalStateException: Fragment music.ControlPanel did not create a view.**
[MonoDroid] at android.app.Activity.onCreateView(Activity.java:4687)
[MonoDroid] at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
[MonoDroid] ... 23 more
[mono-rt] Stacktrace:
[mono-rt]
[mono-rt] at <unknown> <0xffffffff>
[mono-rt] at (wrapper managed-to-native) object.wrapper_native_0xb66db840 (intptr,intptr,intptr) <IL 0x00027, 0xffffffff>
[mono-rt] at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr) [0x00040] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:174
[mono-rt] at Java.Lang.Throwable.get_Message () [0x00043] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Java.Lang.Throwable.cs:207
[mono-rt] at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
[mono-rt] at <unknown> <0xffffffff>
[mono-rt] at (wrapper dynamic-method) object.7354a995-f9d8-457d-8806-4fc45cf85429 (intptr,intptr,intptr) <IL 0x00034, 0x00073>
[mono-rt] at (wrapper native-to-managed) object.7354a995-f9d8-457d-8806-4fc45cf85429 (intptr,intptr,intptr) <IL 0x00023, 0xffffffff>
[mono-rt]
[mono-rt] =================================================================
[mono-rt] Got a SIGSEGV while executing native code. This usually indicates
[mono-rt] a fatal error in the mono runtime or one of the native libraries
[mono-rt] used by your application.
[mono-rt] =================================================================
[mono-rt]
[libc] Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 3201 (DMusic.Music)
The mobile version works great, but the tablet version gives the above error. tablet layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
android:id="@+id/frags">
<fragment
class="music.ControlPanel"
android:id="@+id/fragment_container"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent" />
<fragment
android:name="music.DiceFragment"
android:id="@+id/fragment2"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent" />
</LinearLayout>
Mobile layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_fragment"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@+id/fragment_container"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
My MainActivity.cs
namespace Music
{
[Activity (Label = "Music",LaunchMode = Android.Content.PM.LaunchMode.SingleTask, MainLauncher = true, ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait)]
public class MainActivity : Activity, ActionBar.ITabListener
...
var detailsFrame = this.FindViewById<View>(Resource.Id.fragment2);
var _isDualPane = detailsFrame != null && detailsFrame.Visibility == ViewStates.Visible;
if (_isDualPane)
{
RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;
FragmentTransaction fragmentTx = this.FragmentManager.BeginTransaction ();
fragmentTx.SetTransition (FragmentTransit.FragmentFade);
DiceFragment aDifferentDetailsFrag = new DiceFragment ();
fragmentTx.Replace(Resource.Id.fragment2, aDifferentDetailsFrag);
fragmentTx.AddToBackStack(null);
fragmentTx.Commit();
} else
RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;
SetContentView (Resource.Layout.Main);
}
Thursday, March 12, 2015 6:14 PM
3 times
Thursday, March 12, 2015 6:14 PM
Repeated, sorry about that
Saturday, June 4, 2016 8:18 PM
Hello there,
I was custom styling the buttons by using custom xml file inside the drawable folder. I was getting the following error: Binary XML file line #1: Error inflating class button
This issues almost made me break my head.
But I resolved it. I believe it happens because either the XML is not properly formatted (missing < or > OR spelling mistakes) or incorrect xmlns:android URL.
Also make sure please that in .axml file, when you specify the xml as background or whatever, use this format: android:background="@drawable/yourxmlfilenamewithoutfiletype"_
Thanks and Cheers!
Monday, June 27, 2016 10:29 AM
In my case this exception was caused by the package name. Just in case someone else has the same issue you can find below what I found at the very bottom of the following link:
It is very important to remember that when adding a fragment to a layout file, that Android expects the package name to be lower-case. If the package name is upper-case then an Android.Views.InflateException will be thrown.
Wednesday, June 29, 2016 3:02 PM
In my case, the problem was caused by the fact that I failed to return the correct value. I believe the line with the return below was auto generated for me, and as a result I didn't look at it too closely and didn't notice that it was returning the wrong thing.
``` public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); View v = inflater.Inflate(Resource.Layout.FragmentBoardSelect, container, false);
return base.OnCreateView(inflater, container, savedInstanceState);
}
```
All I had to do was return the view:
return v;
I hope this helps someone.
Tuesday, October 11, 2016 9:57 AM
I've got same issue from Fabric/Crashlytics.
Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{com.roadrunner.roadrunner/md5a15ede4416f5984e314bb34fcaaef442.RidePaymentActivity}: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class
my axml file is following
** ... ... ...
**
activity
** using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; using Android.Text;
using RoadRunner.Shared; using RoadRunner.Shared.Classes;
using GalaSoft.MvvmLight.Helpers;
namespace RoadRunner.Android { [Activity (Label = "RidePaymentActivity")]
public class RidePaymentActivity : BaseActivity { private static bool IsFirstTime = true;
ImageView m_imgPayment;
Spinner m_spPayment;
Switch m_switchMeetGreet;
List<KeyValuePair<object, string>> m_listCreditCards;
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
SetContentView(Resource.Layout.RidePayment);
AppSettings.currentActivity = this;
m_imgPayment = (ImageView)FindViewById(Resource.Id.imgPayment);
var btnAddPayment = (ImageView)FindViewById(Resource.Id.btnAddPayment);
btnAddPayment.Click += (object sender, EventArgs e) =>
{
StartActivity(new Intent(this, typeof(AddPaymentActivity)));
OverridePendingTransition(Resource.Animation.fromLeft, Resource.Animation.toRight);
};
m_spPayment = (Spinner)FindViewById(Resource.Id.spPayment);
var txtPromoCode = (EditText)FindViewById(Resource.Id.txtPromoCode);
txtPromoCode.TextChanged += OnPromoCodeChanged;
var spGratuity = (Spinner)FindViewById(Resource.Id.spGratuity);
if (Facade.Instance.CurrentRide.SelectedFare.serviceid == "0")
{
spGratuity.Enabled = false;
}
var adapter = new ArrayAdapter(this, Resource.Layout.item_spinner);
spGratuity.Adapter = adapter;
adapter.Add("10%");
adapter.Add("15%");
adapter.Add("20%");
spGratuity.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(OnGratuityChanged);
m_switchMeetGreet = (Switch)FindViewById(Resource.Id.switchMeetGreet);
m_switchMeetGreet.CheckedChange += delegate (object sender, CompoundButton.CheckedChangeEventArgs e)
{
Facade.Instance.CurrentRide.IsMeetandGreet = e.IsChecked;
};
var spExtraBags = (Spinner)FindViewById(Resource.Id.spExtraBags);
var adapter1 = new ArrayAdapter(this, Resource.Layout.item_spinner);
spExtraBags.Adapter = adapter1;
for (var i = 1; i < 10; i++)
{
adapter1.Add(i);
}
spExtraBags.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(OnExtraBagsChanged);
if (IsFirstTime)
{
IsFirstTime = false;
SetBindingsOnce();
}
var btnGotoRideConfirmation = (Button)FindViewById (Resource.Id.btn_GoToRideConfirmation);
btnGotoRideConfirmation.SetCommand("Click", Facade.Instance.CurrentRide.GoToTheRideConfirmation);
var btnBack = (ImageButton)FindViewById (Resource.Id.btn_back);
btnBack.Click += delegate(object sender , EventArgs e )
{
OnBack();
};
GetSpecialServices();
}
protected override void OnResume()
{
base.OnResume();
LoadCreditCards();
}
private void LoadCreditCards()
{
try
{
ShowLoadingView("Loading data...");
var dic = new Dictionary<String, String>
{
{Constant.GETCREDITCARDDETAILSNEWFORPHONE_CUSTOMERID, AppSettings.UserID},
{Constant.GETCREDITCARDDETAILSNEWFORPHONE_LOGINTYPE, "-1"},
{Constant.GETCREDITCARDDETAILSNEWFORPHONE_TOKENID, string.Empty } // do not use the actual token
};
String result = String.Empty;
Task runSync = Task.Factory.StartNew(async () =>
{
result = await AppData.ApiCall(Constant.GETCREDITCARDDETAILSNEWFORPHONE, dic);
var tt = (GetCreditCardDetailsNewForPhoneResponse)AppData.ParseResponse(Constant.GETCREDITCARDDETAILSNEWFORPHONE, result);
m_listCreditCards = new List<KeyValuePair<object, string>>();
var listCreditCardImages = new List<KeyValuePair<object, object>>();
RunOnUiThread(() =>
{
var adapter = new ArrayAdapter(this, Resource.Layout.item_spinner);
m_spPayment.Adapter = adapter;
foreach (var card in tt.CardList)
{
m_listCreditCards.Add(new KeyValuePair<object, string>(card.Id, card.CardNumber));
adapter.Add(card.CardNumber);
}
m_spPayment.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(OnPaymentChanged);
});
HideLoadingView();
});
}
catch (Exception e)
{
RunOnUiThread(() =>
{
ShowMessageBox(null, e.Message);
});
}
}
...
public async void GetSpecialServices()
{
try
{
//ShowLoadingView("Loading data...");
var ride = new Ride();
var specialServices = await ride.GetSpecialService();
var arrSpcialServices = specialServices.SpecialServices;
m_switchMeetGreet.Enabled = specialServices.IsMeetAndGreetAvailable;
Facade.Instance.CurrentRide.MeetandGreetFee = 0;
Facade.Instance.CurrentRide.ExtraBagsFee = 0;
for (int i = 0; i < arrSpcialServices.Count; i++)
{
if (specialServices.MeetAndGreetProductID == arrSpcialServices[i].ProductID)
{
Facade.Instance.CurrentRide.MeetandGreetFee = double.Parse(arrSpcialServices[i].Price);
}
if (specialServices.AdditionalBaggageProductID == arrSpcialServices[i].ProductID)
{
Facade.Instance.CurrentRide.ExtraBagsFee = double.Parse(arrSpcialServices[i].Price);
}
}
var lblExtraBags = (TextView)FindViewById(Resource.Id.lblExtraBags);
lblExtraBags.Text = string.Format("* ${0} per extra bag", specialServices.AdditionalBaggageCost.ToString());
var lblMeetandGreetFee = (TextView)FindViewById(Resource.Id.lblMeetandGreetFee);
lblMeetandGreetFee.Text = string.Format("Yes ({0:C} fee)", specialServices.MeetAndGreetCost);
if (specialServices.MeetAndGreetCost == 0)
{
m_switchMeetGreet.Selected = false;
m_switchMeetGreet.Enabled = false;
}
//HideLoadingView();
}
catch (Exception e)
{
}
}
private void SetBindingsOnce()
{
this.SetBinding(
() => Facade.Instance.CurrentRide.CanGoToTheRideConfirmation)
.UpdateSourceTrigger("CanGoToTheRideConfirmationChanges")
.WhenSourceChanges(
async () =>
{
if (Facade.Instance.CurrentRide.CanGoToTheRideConfirmation)
{
AppSettings.currentActivity.StartActivity(new Intent(this, typeof(RideConfirmationActivity)));
AppSettings.currentActivity.OverridePendingTransition(Resource.Animation.fromLeft, Resource.Animation.toRight);
}
else {
if (Facade.Instance.CurrentRide.ValidaionError != null && Facade.Instance.CurrentRide.ValidaionError.Count > 0)
{
string header = Constant.SUPPORT_NAME;
var delimeter = System.Environment.NewLine + System.Environment.NewLine;
var message = String.Join(delimeter, Facade.Instance.CurrentRide.ValidaionError.Select(r => r.ErrorMessage));
AppSettings.currentActivity.ShowMessageBox(header, message);
}
}
});
}
}
}
**
I've wasted many time with this issue but couldn't find any solution in anywhere.
Please help me
Tuesday, October 11, 2016 10:00 AM
I've attached above .AXML and .cs files.
Thanks
Saturday, October 22, 2016 10:41 AM
I'm new to Xamarin, I got the same error, I was trying to make a Maps fragment in the app, can someone help me?
<Fragment
class="com.google.android.gms.map.MapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Monday, November 14, 2016 3:03 AM
The way i fixed this error was clean and rebuild. And the rebuild might take longer than it should, try it out, worked for me
Wednesday, January 18, 2017 11:55 AM
at wrong window
Saturday, January 21, 2017 2:24 PM
Hi! I have the same problem -> Android.Views.InflateException: Binary XML file line #1: Error inflating class GrumsonLed
I don't know what is wrong! Can someone please help me!
Below is the code!
Costum view class:
` " namespace controls {
[Register("GrumsonLed")]
class GrumsonLed : View {
#region *** CONSTRUCTOR ***
public GrumsonLed ( Context context ) : base(context) { }
public GrumsonLed ( Context context, IAttributeSet attrs ) : base(context, attrs) { }
public GrumsonLed ( Context context, IAttributeSet attrs, int defStyle ) : base(context, attrs, defStyle) { }
public GrumsonLed ( Context context, IAttributeSet attrs, int defStyle, int defStyleRes ) : base(context, attrs, defStyle, defStyleRes) { }
public GrumsonLed ( IntPtr handle, JniHandleOwnership owner ) : base(handle, owner) { }
#endregion constructor
#region *** ON DRAW ***
protected override void OnDraw ( Canvas canvas ) {
base.OnDraw(canvas);
Paint glassPaint = new Paint {
AntiAlias = true,
Color = Color.Red,
};
canvas.DrawLine(0, 0, this.Width, this.Height, glassPaint);
}//end OnDraw()
#endregion OnDraw
}
} " `
axml file:
" <?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" android:minWidth="25px" android:minHeight="25px"> <Button android:text="Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/button1" /> <controls.GrumsonLed android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/led" /> </LinearLayout> "
and Activity:
`
[Activity(Label = "CostumControls", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity: Activity {
private GrumsonLed led;
protected override void OnCreate ( Bundle bundle ) {
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
led = FindViewById<GrumsonLed>(Resource.Id.led);
}
}//end class
`
Monday, January 30, 2017 4:59 AM
I also see the same exception below and I am using xamarin.form so i dont have any android ui files with wrong package names like others have indicated.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shegerapps.amharicradio/md5f4ff9aca81ae61c6139a6689bc9c6600.MainActivity}: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class android.support.v7.widget.FitWindowsLinearLayout at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) at android.app.ActivityThread.access$1100(ActivityThread.java:221) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7225) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class android.support.v7.widget.FitWindowsLinearLayout at android.view.LayoutInflater.inflate(LayoutInflater.java:551) at android.view.LayoutInflater.inflate(LayoutInflater.java:429) at android.view.LayoutInflater.inflate(LayoutInflater.java:380) at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:413) at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:309) at android.support.v7.app.AppCompatDelegateImplV7.initWindowDecorActionBar(AppCompatDelegateImplV7.java:171) at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:88) at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:195) at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:126) at md5f4ff9aca81ae61c6139a6689bc9c6600.MainActivity.n_onCreate(Native Method) at md5f4ff9aca81ae61c6139a6689bc9c6600.MainActivity.onCreate(MainActivity.java:32) at android.app.Activity.performCreate(Activity.java:6876) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) ... 9 more Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.v7.widget.FitWindowsLinearLayout at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) at android.view.LayoutInflater.inflate(LayoutInflater.java:498) ... 22 more Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.FitWindowsLinearLayout" on path: DexPathList[[zip file "/data/app/com.shegerapps.amharicradio-1/base.apk"],nativeLibraryDirectories=[/data/app/com.shegerapps.amharicradio-1/lib/arm, /data/app/com.shegerapps.amharicradio-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at android.view.LayoutInflater.createView(LayoutInflater.java:595) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) ... 24 more Suppressed: java.lang.ClassNotFoundException: android.support.v7.widget.FitWindowsLinearLayout at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 27 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Thursday, February 9, 2017 5:38 AM
Posting if it helps others. I figured what is going go on. This issue was only happening if I have ProGuard enabled and I didnt have the full suggested configu here: https://developer.xamarin.com/guides/android/deployment,*testing,*and_metrics/proguard/
In addition to what is in the cofig file listed in the above link I had to add this
-keep class android.support.v7.widget.* { *; (...); } -keep class com.google.android.gms.ads.* { *; (...); } After I added that to my config this error went away.
Monday, February 20, 2017 10:40 AM
I have the same problem. The app used to work just fine, after updating Xamarin i get the Error: "Binary XML file line #1: Error inflating class android.widget.ProgressBar", in pre lolipop devices only.
I haven't changed anything to my .axml file. The error occurs after the SetContentView() call.
If i comment out the ProgressBar layout then i get error: "Binary XML file line #1: Error inflating class > Java.Lang"
Please help us because this is extremely serious problem.
Thank you in advance.
Monday, February 20, 2017 1:28 PM
are you using any support nuget package?