Xamairin forms : Android.Views.InflateException: <Timeout exceeded getting exception details>

爷,独闯天下 提交于 2019-12-25 00:26:31

问题


Research a lot about this issue and found the same question, which doesn't solve my problem. so starting a new question. Xamarin Android: Android.Views.InflateException - Error when loading Layout

Getting Xamairin forms : Android.Views.InflateException: Timeout exceeded getting exception details when loading layout.

Main.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" 
android:layout_height="match_parent"
android:background="#FFCDD2"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
    android:id="@+id/input_layout_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <EditText
        android:id="@+id/input_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:hint="@string/hint_name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
    android:id="@+id/input_layout_email"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <EditText
        android:id="@+id/input_email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress"
        android:hint="@string/hint_email" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
    android:id="@+id/input_layout_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <EditText
        android:id="@+id/input_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:hint="@string/hint_password" />
</android.support.design.widget.TextInputLayout>
<Button
    android:id="@+id/btn_signup"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/btn_sign_up"
    android:background="@color/colorPrimary"
    android:layout_marginTop="40dp"
    android:textColor="@android:color/white" />
</LinearLayout>

I have not used layout:width and layout:height properties in my axml and only using an icon having 4kb size.

Please suggest a solution for this issue, thanks in advance...


回答1:


Getting Xamairin forms : Android.Views.InflateException: Timeout exceeded getting exception details when loading layout.

There are two things needs to be confirmed before using TextInputLayout:

  1. Please make sure, Xamarin.Android.Support.Design lib is correctly referenced in your Xamarin.Android project. If you are using Xamarin.Forms, it should be referenced by default.

  2. Please make sure the Activity is of type Android.Support.V7.App.AppCompatActivity.

If none of the above things help, please provide a basic demo that can reproduce the problem.

Update:

Upon testing on the project you shared. I found you need to use a Theme.AppCompat theme for your activity, you can do that by following below steps:

  1. Create a styles.xml file under Resources\values\ folder with below codes:

    <?xml version="1.0" encoding="utf-8" ?> 
    <resources>
     <!-- Base application theme. -->
        <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        </style>
    </resources>
    
  2. In MainActivity.cs define the Activity attribute to leverage AppTheme like this:

    [Activity(Label = "DinexFeedback", MainLauncher = true, Icon = "@drawable/icon",Theme ="@style/AppTheme")]
    public class MainActivity : Android.Support.V7.App.AppCompatActivity
    {
       ...
    

Then the project will run fine.




回答2:


Unhandled Exception: Android.Views.InflateException:

Make sure the necessary nuget package installed in visual studio.

I used card view in my project, i got this issue becoz i didn't install Xamarin.Android.Support.cardview.

so we should install all support nuget package in order to support all widgets here i use card view.

click on project -> Manage Nuget-> check out the installed pakages, if the package were not installed just search the particular package and then download it.

updated on 10/12/2018

check your layout whether all the layout fields are started with capital letter. for ex : In android we used in small letter but In c# we should use otherwise it throws the inflate view exception.



来源:https://stackoverflow.com/questions/49344884/xamairin-forms-android-views-inflateexception-timeout-exceeded-getting-excep

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!