android.support.design.widget.TextInputLayout gives InflateException -


i trying use textinputlayout in design library , added support libraries following:

dependencies {     compile filetree(dir: 'libs', include: ['*.jar'])     compile 'com.android.support:appcompat-v7:22.2.1'     compile 'com.google.android.gms:play-services:4.0.30'     compile "com.android.support:support-v4:+"     compile 'com.squareup.picasso:picasso:2.3.2'     compile 'com.nineoldandroids:library:2.4.0'     compile 'com.daimajia.slider:library:1.1.5@aar'     compile 'com.navercorp.pulltorefresh:library:3.2.0@aar'     compile filetree(dir: 'libs', include: 'parse-*.jar')     compile filetree(dir: 'libs', include: 'parsecrashreporting-*.jar')     compile 'uk.co.chrisjenx:calligraphy:2.1.0'     compile 'com.android.support:design:22.2.1' } 

however, gives me following error. might cause of it?

e/androidruntime﹕ fatal exception: main         android.view.inflateexception: binary xml file line #12: error inflating class android.support.design.widget.textinputlayout                 @ android.view.layoutinflater.createview(layoutinflater.java:613)                 @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:687)                 @ android.view.layoutinflater.rinflate(layoutinflater.java:746)                 @ android.view.layoutinflater.inflate(layoutinflater.java:489)                 @ android.view.layoutinflater.inflate(layoutinflater.java:396)                 @ com.myproject.fragments.lostpropertycheckfragment.oncreateview(lostpropertycheckfragment.java:48)                 @ android.support.v4.app.fragment.performcreateview(fragment.java:1789)                 @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:955)                 @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1138)                 @ android.support.v4.app.backstackrecord.run(backstackrecord.java:740)                 @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1501)                 @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:458)                 @ android.os.handler.handlecallback(handler.java:615)                 @ android.os.handler.dispatchmessage(handler.java:92)                 @ android.os.looper.loop(looper.java:137)                 @ android.app.activitythread.main(activitythread.java:4921)                 @ java.lang.reflect.method.invokenative(native method)                 @ java.lang.reflect.method.invoke(method.java:511)                 @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1027)                 @ com.android.internal.os.zygoteinit.main(zygoteinit.java:794)                 @ dalvik.system.nativestart.main(native method)          caused by: java.lang.reflect.invocationtargetexception                 @ java.lang.reflect.constructor.constructnative(native method)                 @ java.lang.reflect.constructor.newinstance(constructor.java:417)                 @ android.view.layoutinflater.createview(layoutinflater.java:587)                 at android.view.layoutinflater.createviewfromtag(layoutinflater.java:687)                 at android.view.layoutinflater.rinflate(layoutinflater.java:746)                 at android.view.layoutinflater.inflate(layoutinflater.java:489)                 at android.view.layoutinflater.inflate(layoutinflater.java:396)                 at com.myproject.fragments.lostpropertycheckfragment.oncreateview(lostpropertycheckfragment.java:48)                 at android.support.v4.app.fragment.performcreateview(fragment.java:1789)                 at android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:955)                 at android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1138)                 at android.support.v4.app.backstackrecord.run(backstackrecord.java:740)                 at android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1501)                 at android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:458)                 at android.os.handler.handlecallback(handler.java:615)                 at android.os.handler.dispatchmessage(handler.java:92)                 at android.os.looper.loop(looper.java:137)                 at android.app.activitythread.main(activitythread.java:4921)                 at java.lang.reflect.method.invokenative(native method)                 at java.lang.reflect.method.invoke(method.java:511)                 at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1027)                 at com.android.internal.os.zygoteinit.main(zygoteinit.java:794)                 at dalvik.system.nativestart.main(native method)          caused by: java.lang.unsupportedoperationexception: can't convert color: type=0x2                 @ android.content.res.typedarray.getcolor(typedarray.java:326)                 @ android.support.design.widget.collapsingtexthelper.setcollapsedtextappearance(collapsingtexthelper.java:166)                 @ android.support.design.widget.textinputlayout.<init>(textinputlayout.java:124)                 at java.lang.reflect.constructor.constructnative(native method)                 at java.lang.reflect.constructor.newinstance(constructor.java:417)                 at android.view.layoutinflater.createview(layoutinflater.java:587)                 at android.view.layoutinflater.createviewfromtag(layoutinflater.java:687)                 at android.view.layoutinflater.rinflate(layoutinflater.java:746)                 at android.view.layoutinflater.inflate(layoutinflater.java:489)                 at android.view.layoutinflater.inflate(layoutinflater.java:396)                 at com.myproject.fragments.lostpropertycheckfragment.oncreateview(lostpropertycheckfragment.java:48)                 at android.support.v4.app.fragment.performcreateview(fragment.java:1789)                 at android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:955)                 at android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1138)                 at android.support.v4.app.backstackrecord.run(backstackrecord.java:740)                 at android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1501)                 at android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:458)                 at android.os.handler.handlecallback(handler.java:615)                 at android.os.handler.dispatchmessage(handler.java:92)                 at android.os.looper.loop(looper.java:137)                 at android.app.activitythread.main(activitythread.java:4921)                 at java.lang.reflect.method.invokenative(native method)                 at java.lang.reflect.method.invoke(method.java:511)                 at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1027)                 at com.android.internal.os.zygoteinit.main(zygoteinit.java:794)                 at dalvik.system.nativestart.main(native method) 

xml

<?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="fill_parent"     android:layout_marginright="10dp"     android:layout_marginleft="10dp"     android:layout_margintop="70dp"     android:background="@color/white"     android:clickable="true"     android:orientation="vertical" >      <android.support.design.widget.textinputlayout         android:id="@+id/text_input_layout"         android:layout_width="match_parent"         android:layout_height="wrap_content">         <edittext             android:id="@+id/trackno"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:hint="@string/track_no"             android:inputtype="number" />     </android.support.design.widget.textinputlayout>      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:gravity="right|center_vertical"         android:layout_margintop="5dp">          <button             android:id="@+id/check"             android:layout_width="wrap_content"             android:layout_height="match_parent"             android:background="@color/fav_light_green"             android:gravity="center"             android:padding="5dp"             android:text="@string/check"             android:textcolor="@color/white" >         </button>     </linearlayout>  </linearlayout> 

fragment

public class lostpropertycheckfragment extends fragment {      edittext trackno;     button check;     dialog dialog;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         // arguments     }      @override     public view oncreateview(layoutinflater inflater, viewgroup container,             bundle savedinstancestate) {         // defines xml file fragment         view view = inflater.inflate(r.layout.lostpropertycheck_fragment,                 container, false);          trackno = (edittext) view.findviewbyid(r.id.trackno);         check = (button) view.findviewbyid(r.id.check);          check.setonclicklistener(new view.onclicklistener() {              @override             public void onclick(view v) {                  if (trackno.gettext().tostring().trim().equalsignorecase("")) {                     toast.maketext(                             getactivity(),                             getactivity().getresources().getstring(                                     r.string.formwarning), toast.length_long)                             .show();                 }                  else {                     new checklostproperty().execute();                 }              }         });          return view;     }      private boolean isnetworkavailable() {         connectivitymanager connectivitymanager = (connectivitymanager) getactivity()                 .getsystemservice(context.connectivity_service);         networkinfo activenetworkinfo = connectivitymanager                 .getactivenetworkinfo();         return activenetworkinfo != null && activenetworkinfo.isconnected();     }      public static lostpropertycheckfragment newinstance() {         lostpropertycheckfragment fragment = new lostpropertycheckfragment();          return fragment;     } 

styles

<resources>      <!--         base application theme, dependent on api level. theme replaced         appbasetheme res/values-vxx/styles.xml on newer devices.      -->     <style name="appbasetheme" parent="theme.appcompat.light.noactionbar">         <!--             theme customizations available in newer api levels can go in             res/values-vxx/styles.xml, while customizations related             backward-compatibility can go here.          -->     </style>      <!-- application theme. -->     <style name="apptheme" parent="appbasetheme">         <!-- customizations not specific particular api-level can go here. -->         <!--<item name="android:textviewstyle">@style/apptheme.widget.textview</item>-->        <!-- <item name="textfieldstyle">@style/icontextviewstyle</item>-->     </style>      <style name="icontextviewstyle"         parent="android:widget.textview">         <item name="fontpath">fonts/icomoon.ttf</item>     </style>      <attr name="textfieldstyle"         format="reference" />        <!--<style name="apptheme.widget"/>      <style name="apptheme.widget.textview" parent="android:widget.holo.light.textview">         <item name="fontpath">fonts/opensansregular.ttf</item>     </style>-->  </resources> 

you should try few things fix problem.

  • extend activity appcompatactivity
  • extend fragment android.support.v4.app.fragment (you need add support library in build.gradle file, if not added).
  • you should use 22.2.1 or later version of design library (at time of posting, latest version 'com.android.support:design:23.0.0') correct 'hint' behaviour on lollipop , above devices. if use lower version 22.2.1 , face issue discussed on stackoverflow. (in case using 22.2.1).
  • instead of using edittext, use android.support.v7.widget.appcompatedittext.

    • for example:

      <android.support.design.widget.textinputlayout                 android:id="@+id/tl_firstname"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 app:errorenabled="true">                  <android.support.v7.widget.appcompatedittext                     android:id="@+id/edittext_firstname"                     style="@style/editprofile_edittext"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:hint="first name"                     android:inputtype="textpersonname"                     android:singleline="true" />  </android.support.design.widget.textinputlayout> 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -