1. Are you ready for the Galaxy S20? Here is everything we know so far!

TextInputLayout crashes

Discussion in 'Android Development' started by Federico Desia, Mar 30, 2019.

  1. Federico Desia

    Thread Starter

    Code (Java):
    1. if (StringName.isEmpty()){
    2.             name.setError("Complete this.");
    3. }
     

    Advertisement

  2. GameTheory

    GameTheory Android Expert

    What does the logcat say? Post the logcat.

    You'll probably need to post more code than that so that anyone can help you.
     
  3. Deleted User

    Deleted User Guest

    As above, the problem is impossible to diagnose from the information given.
    Need to see the Logcat, with stack trace. And more of the code.
     
    GameTheory likes this.
  4. Federico Desia

    Thread Starter

    Java:
    Code (Java):
    1. private TextInputLayout TextInputName;
    2. private EditText name;
    3.  
    4. CODE without errors...
    5.  
    6. TextInputName=findViewById(R.id.register_textinput_name1);
    7.  
    8. CODE without errors...
    9.  
    10. String stringName=name.getText().toString().trim();
    11.        
    12. if (stringName.isEmpty()){
    13.    TextInputName.setError("Enter your name");
    14. }
    15.  
    16. CODE without errors...
    Xml:
    Code (Text):
    1.             <android.support.design.widget.TextInputLayout
    2.                 android:id="@+id/register_textinput_name1"
    3.                 android:layout_width="match_parent"
    4.                 android:layout_height="wrap_content"
    5.                 android:layout_below="@id/register_textview_title"
    6.                 android:layout_marginTop="30dp"
    7.                 android:layout_marginStart="20dp"
    8.                 android:layout_marginEnd="20dp"
    9.  
    10.                 android:background="@drawable/background_textinput"
    11.                 android:paddingLeft="4dp"
    12.                 android:paddingRight="4dp"
    13.                 android:paddingTop="10dp"
    14.                 android:paddingBottom="4dp"
    15.                 android:theme="@style/TextInput"
    16.                 app:errorEnabled="true">
    17.                 <android.support.design.widget.TextInputEditText
    18.                     android:id="@+id/register_textinput_name2"
    19.                     android:layout_width="match_parent"
    20.                     android:layout_height="wrap_content"
    21.                     android:layout_marginLeft="8dp"
    22.                     android:layout_marginRight="8dp"
    23.  
    24.                     android:inputType="textPersonName"
    25.                     android:hint="Nombre"
    26.                     android:textColor="@color/colorWhite"
    27.                     android:textColorHint="@color/colorWhite"
    28.                     android:shadowColor="@color/colorWhite"
    29.                     android:textColorLink="@color/colorWhite"
    30.                     android:textColorHighlight="@color/colorWhite"
    31.                     android:textSize="14dp"/>
    32.             </android.support.design.widget.TextInputLayout>

    styles.xml:
    Code (Text):
    1. <resources>
    2.  
    3.     <!-- Base application theme. -->
    4.     <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    5.         <!-- Customize your theme here. -->
    6.         <item name="colorPrimary">@color/colorPrimary</item>
    7.         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    8.         <item name="colorAccent">@color/colorAccent</item>
    9.     </style>
    10.  
    11.     <style name="TextInput" parent="TextAppearance.AppCompat">
    12.         <item name="colorAccent">@color/colorWhite</item>
    13.         <item name="colorControlNormal">@color/colorWhite</item>
    14.         <item name="colorControlActivated">@color/colorWhite</item>
    15.         <item name="textColorError">@color/colorWhite</item>
    16.     </style>
    17. </resources>
    18.  
    Logcat:
    Code (Text):
    1.  
    2. 03-31 23:06:34.560 13199-13199/com.example.fdesia.app E/AndroidRuntime: FATAL EXCEPTION: main
    3.     Process: com.example.fdesia.app, PID: 13199
    4.     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fdesia.app/com.example.fdesia.app.RegisterActivity}: android.view.InflateException: Binary XML file line #69: Binary XML file line #69: Error inflating class android.support.design.widget.TextInputLayout
    5.         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
    6.         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
    7.         at android.app.ActivityThread.access$1100(ActivityThread.java:229)
    8.         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
    9.         at android.os.Handler.dispatchMessage(Handler.java:102)
    10.         at android.os.Looper.loop(Looper.java:148)
    11.         at android.app.ActivityThread.main(ActivityThread.java:7406)
    12.         at java.lang.reflect.Method.invoke(Native Method)
    13.         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    14.         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
    15.      Caused by: android.view.InflateException: Binary XML file line #69: Binary XML file line #69: Error inflating class android.support.design.widget.TextInputLayout
    16.         at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
    17.         at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
    18.         at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
    19.         at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
    20.         at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    21.         at com.example.fdesia.app.RegisterActivity.onCreate(RegisterActivity.java:36)
    22.         at android.app.Activity.performCreate(Activity.java:6904)
    23.         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
    24.         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
    25.         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
    26.         at android.app.ActivityThread.access$1100(ActivityThread.java:229)
    27.         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
    28.         at android.os.Handler.dispatchMessage(Handler.java:102)
    29.         at android.os.Looper.loop(Looper.java:148)
    30.         at android.app.ActivityThread.main(ActivityThread.java:7406)
    31.         at java.lang.reflect.Method.invoke(Native Method)
    32.         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    33.         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
    34.      Caused by: android.view.InflateException: Binary XML file line #69: Error inflating class android.support.design.widget.TextInputLayout
    35.         at android.view.LayoutInflater.createView(LayoutInflater.java:657)
    36.         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
    37.         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
    38.         at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
    39.         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    40.         at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
    41.         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    42.         at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
    43.         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    44.         at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
    45.         at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
    46.         at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
    47.         at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
    48.         at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    49.         at com.example.fdesia.app.RegisterActivity.onCreate(RegisterActivity.java:36)
    50.         at android.app.Activity.performCreate(Activity.java:6904)
    51.         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
    52.         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
    53.         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
    54.         at android.app.ActivityThread.access$1100(ActivityThread.java:229)
    55.         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
    56.         at android.os.Handler.dispatchMessage(Handler.java:102)
    57.         at android.os.Looper.loop(Looper.java:148)
    58.         at android.app.ActivityThread.main(ActivityThread.java:7406)
    59.         at java.lang.reflect.Method.invoke(Native Method)
    60.         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    61.         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
    62.      Caused by: java.lang.reflect.InvocationTargetException
    63.         at java.lang.reflect.Constructor.newInstance(Native Method)
    64.         at android.view.LayoutInflater.createView(LayoutInflater.java:631)
    65.         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
    66.         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
    67.         at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
    68.         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    69.         at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
    70.         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    71.         at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
    72.         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    73.         at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
    74.         at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
    75.         at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
    76.         at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
    77.         at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    78.         at com.example.fdesia.app.RegisterActivity.onCreate(RegisterActivity.java:36)
    79.         at android.app.Activity.performCreate(Activity.java:6904)
    80.         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
    81.         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
    82.         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
    83.         at android.app.ActivityThread.access$1100(ActivityThread.java:229)
    84.         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
    85.         at android.os.Handler.dispatchMessage(Handler.java:102)
    86.         at android.os.Looper.loop(Looper.java:148)
    87.         at android.app.ActivityThread.main(ActivityThread.java:7406)
    88.         at java.lang.reflect.Method.invoke(Native Method)
    89.         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    90.         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
    91.      Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 24: TypedValue{t=0x3/d=0x1a6 "res/color/secondary_text_material_light.xml" a=1 r=0x10601e9}
    92.         at android.content.res.TypedArray.getColor(TypedArray.java:449)
    93.         at android.widget.TextView.<init>(TextView.java:1036)
    94.         at android.widget.TextView.<init>(TextView.java:957)
    95.         at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:76)
    96.         at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:72)
    97.         at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:68)
    98.         at android.support.design.widget.TextInputLayout.setErrorEnabled(TextInputLayout.java:628)
    99.         at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:257)
    100.         at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:187)
    101.         at java.lang.reflect.Constructor.newInstance(Native Method)
    102.         at android.view.LayoutInflater.createView(LayoutInflater.java:631)
    103.         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
    104.         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
    105.         at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
    106.         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    107.         at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
    108.         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    109.         at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
    110.         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    111.         at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
    112.         at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
    113.         at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
    114.         at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
    115.         at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    116.         at com.example.fdesia.app.RegisterActivity.onCreate(RegisterActivity.java:36)
    117.         at android.app.Activity.performCreate(Activity.java:6904)
    118.         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
    119.         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
    120.         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
    121.         at android.app.ActivityThread.access$1100(ActivityThread.java:229)
    122.         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
    123.         at android.os.Handler.dispatchMessage(Handler.java:102)
    124.         at android.os.Looper.loop(Looper.java:148)
    125.         at android.app.ActivityThread.main(ActivityThread.java:7406)
    126.         at java.lang.reflect.Method.invoke(Native Method)
    127.         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    128.         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
    129.  
     
  5. Deleted User

    Deleted User Guest


    There's a problem in your layout file at line 69. So you need to show the entire contents of your XML layout file, rather than a small fragment, so we can see what's at line 69.

    Seems to be a problem with a missing resource

     
    GameTheory likes this.
  6. Varish Ali

    Varish Ali Lurker

    String stringName=name.getText().toString().trim();
    In this line write String stringName = TextInputName.getText().toString().trim();
     
  7. Deleted User

    Deleted User Guest

    How will that solve the problem as described, with the issue highlighted in the stack trace? It is not related.
     
  8. Varish Ali

    Varish Ali Lurker

    Actually I am a newbie in Code. I thought that he actually didn't getting text from a Text view which he is finding in this code.
    TextInputName=findViewById(R.id.register_textinput_name1);
    So I thought this code solve his problem
     
  9. Deleted User

    Deleted User Guest

    Thanks for the input, but let's not confuse the issue. The stack trace from the Logcat is your first clue to diagnose the problem. But we do need to see a full and complete XML layout file, to match up the line number shown in the stack trace.
     
    GameTheory likes this.
  10. Federico Desia

    Thread Starter

    Thanks, I already solve the problem.
     
Loading...

Share This Page

Loading...