Im working on an android app and when I test it on devices/emulators with api 21 and lower it crashes and gives me a message in the logs:
09-29 07:32:30.349 6212-6212/org.jazmawy.mahmood.vocabulary
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.jazmawy.mahmood.vocabulary, PID: 6212
java.lang.RuntimeException: Unable to start activity
ComponentInfo{org.jazmawy.mahmood.vocabulary/org.jazmawy.mahmood.vocabulary.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class ImageView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at
org.jazmawy.mahmood.vocabulary.MainActivity.onCreate(MainActivity.java:52)
if I remove the XML elements the app launches and prompts to MainActivity
and It seems that screen sizes doesn't affect the result to my observation its due to the API but i could be wrong
Here is the XML code
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/green"
android:contentDescription="#string/app_name" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="4dp"
android:layout_marginTop="16dp"
android:orientation="vertical"
android:weightSum="4"
app:layout_constraintBottom_toTopOf="#+id/mainActivityAdView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="#+id/button11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/vocabulary_button"
android:onClick="openUnitActivity" />
<Button
android:id="#+id/button13"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/collection_button"
android:onClick="collectionOnClick" />
<Button
android:id="#+id/button9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/contact_us_button"
android:onClick="contactsUsOnClick" />
<Button
android:id="#+id/button14"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/aboutus_button"
android:onClick="aboutUsOnClick" />
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/mainActivityAdView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
ads:adSize="BANNER"
ads:adUnitId="AD_UNIT_ID"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
I tried cleaning some unnecessary XML attributes but it doesn't help
What should I try next?
its quite simple paste your image into the drawable and change tha path into app\src\main\res\drawable
Related
I'm seeing the following exception in crash logs:
android.app.RemoteServiceException: Bad notification posted from package XXX: Couldn't inflate contentViewsandroid.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class com.google.android.material.appbar.AppBarLayout
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
But, my custom notification layout has never defined this class label:com.google.android.material.appbar.AppBarLayout
Moreover, my custom layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/local_push_bg_color"
android:orientation="vertical"
android:padding="#dimen/dp_6">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/dp_26">
<TextView
android:id="#+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:drawableStart="#drawable/ic_local_push_logo"
android:drawablePadding="#dimen/dp_6"
android:maxLines="1"
android:textStyle="bold"
android:textColor="#color/local_push_title_text_color"
android:text="#string/local_push_title"
android:textSize="#dimen/sp_14"
tools:ignore="RelativeOverlap" />
<ImageView
android:id="#+id/iv_next"
android:layout_width="#dimen/dp_26"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_local_push_next"
tools:ignore="ContentDescription" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/v_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="#dimen/dp_10"
android:layout_weight="1">
<ImageView
android:id="#+id/iv_push_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
tools:ignore="ContentDescription" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/shape_bg_local_push_content" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/ic_local_push_play" />
<TextView
android:id="#+id/tv_push_content_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="#dimen/dp_10"
android:ellipsize="end"
android:textStyle="bold"
android:maxLines="2"
tools:text="asdaksjdllasfjasldjkasfljkaslkfjlsjafsafjk"
android:textColor="#color/c_white"
android:textSize="#dimen/sp_14" />
</RelativeLayout>
<LinearLayout
android:id="#+id/v_search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp_10"
android:background="#drawable/shape_bg_local_push_search"
android:orientation="horizontal"
android:padding="#dimen/dp_8">
<TextView
android:id="#+id/tv_push_search_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawableStart="#drawable/ic_local_push_search"
android:drawablePadding="#dimen/dp_6"
android:ellipsize="end"
android:maxLines="1"
tools:text="what the fk"
android:textColor="#color/local_push_search_text_color"
android:textSize="#dimen/sp_12" />
</LinearLayout>
</LinearLayout>
as you see, There is no class label reported above.
So far, we have found three different error messages for the same
custom notification layout:
Error inflating class com.google.android.material.appbar.AppBarLayout
Error inflating class android.support.design.widget.AppBarLayout
Error inflating class android.widget.TextView
After target my apps to api 28, Fabric shows me some crashes that said:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mydomain.myapp/com.mydomain.myapp.SplashScreen}: android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2330)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5278)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at base.activity.BaseSplash.onCreate(BaseSplash.java:149)
at com.mydomain.myapp.SplashScreen.onCreate(SplashScreen.java:77)
In all kinds of devices and in the splash screen but only on less than 0.1% of the users. Before target to API 28 I did not have this error.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bckgrnd_splash">
<View
android:id="#+id/grass"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#color/grass"
android:layout_alignParentBottom="true"/>
<View
android:background="#drawable/grass"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:id="#+id/grassImage"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<View
android:background="#drawable/road_bckgrnd"
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/roadView"
android:layout_above="#+id/grass"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<View
android:background="#color/grassRoad"
android:layout_width="match_parent"
android:layout_height="30dp"
android:id="#+id/topRoadView"
android:layout_above="#+id/roadView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<View
android:id="#+id/buildins"
android:background="#drawable/buildings_cloud"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_above="#+id/topRoadView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageView
android:paddingTop="20dp"
android:src="#drawable/splash_bus_sitp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/grassImage"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:id="#+id/sitpImage" />
<ImageView
android:id="#+id/taxiImage"
android:src="#drawable/splash_taxi"
android:layout_above="#id/grass"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"/>
<ImageView
android:id="#+id/tmImage"
android:src="#drawable/splash_bus_tm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:layout_above="#+id/grassImage"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageView
android:id="#+id/cloudLeft"
android:layout_marginTop="32dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:src="#drawable/splash_cloud_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/logo"
android:layout_marginTop="48dp"
android:layout_below="#id/cloudLeft"
android:src="#drawable/splash_logo"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:layout_marginTop="32dp"
android:layout_below="#id/logo"
android:layout_alignParentRight="true"
android:src="#drawable/splash_cloud_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
Someone can help me with this issue? or maybe know something about that? Line #14 is the second view.
Thanks for your help.
Note: My app is working fine on old device android 5.But i am geeting this problem in newer versions.Now i have added the code for login and spinner....
I think it may be the problem of density pixels of images..or placing the things in wrong places.I need time from experts.Kindly Solve my problem.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawable="#color/colorAccent"
tools:context=".LoginActivity">
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="0dp"
android:layout_height="512dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<LinearLayout
android:layout_marginTop="60dp"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="98dp"
android:elevation="4dp"
app:srcCompat="#drawable/logo_new"
tools:ignore="ContentDescription,UnusedAttribute" />
<android.support.design.widget.TextInputLayout
style="auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">
<EditText
android:id="#+id/tv_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/username"
android:imeOptions="actionNext"
android:inputType="text"
android:lines="1"
android:textSize="20sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/tv_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:lines="1"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Display1"
android:textSize="20sp"
tools:inputType="textPassword|textVisiblePassword" />
</android.support.design.widget.TextInputLayout>
<Button
android:onClick="login"
android:id="#+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:elevation="4dp"
android:text="#string/log_in"
android:textAllCaps="false"
android:textColor="#ffff" />
<TextView
android:textColor="#701212"
android:layout_marginTop="6dp"
android:layout_gravity="center"
android:text="#string/forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="15dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:popupBackground="?android:attr/textColorHighlightInverse"
android:theme="#style/AlertDialog.AppCompat.Light"/>
</RelativeLayout>
<View
android:background="#701212"
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="450dp"
android:layout_marginBottom="17dp"
app:layout_constraintBottom_toTopOf="#+id/textView3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_marginTop="10dp"
android:textColor="#097779"
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/designed_and_develop_by"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/view" />
<TextView
android:layout_marginTop="4dp"
android:textStyle="bold"
android:textColor="#730b72"
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="11dp"
android:text="#string/db_scholars"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/view" />
</android.support.constraint.ConstraintLayout>
.
Thanks in advance
Process: com.example.muhammadobaid.sims, PID: 18834
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.muhammadobaid.sims/com.example.muhammadobaid.sims.LoginActivity}: android.view.InflateException: Binary XML file line #98: Binary XML file line #98: Error inflating class Spinner
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3012)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1716)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:232)
at android.app.ActivityThread.main(ActivityThread.java:6802)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Caused by: android.view.InflateException: Binary XML file line #98: Binary XML file line #98: Error inflating class Spinner
Caused by: android.view.InflateException: Binary XML file line #98: Error inflating class Spinner
Caused by: android.content.res.Resources$NotFoundException: Drawable android:color/highlighted_text_material with resource ID #0x1060118
Caused by: android.content.res.Resources$NotFoundException: File res/color/highlighted_text_material.xml from drawable resource ID #0x1060118
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:1015)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:791)
at android.content.res.Resources.loadDrawable(Resources.java:1019)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.widget.PopupWindow.<init>(PopupWindow.java:286)
at android.widget.ColorPopupWindow.<init>(ColorPopupWindow.java:77)
at android.widget.ColorListPopupWindow.createPopupWindow(ColorListPopupWindow.java:90)
at android.widget.ListPopupWindow.<init>(ListPopupWindow.java:246)
at android.widget.ColorListPopupWindow.<init>(ColorListPopupWindow.java:82)
at android.widget.Spinner$DropdownPopup.<init>(Spinner.java:1202)
at android.widget.Spinner.createDropdownPopup(Spinner.java:1333)
at android.widget.Spinner.<init>(Spinner.java:294)
at android.widget.Spinner.<init>(Spinner.java:222)
at android.widget.Spinner.<init>(Spinner.java:172)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:195)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:166)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:147)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:132)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:115)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1016)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1073)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.muhammadobaid.sims.LoginActivity.onCreate(LoginActivity.java:52)
at android.app.Activity.performCreate(Activity.java:6974)
09-30 22:57:56.275 18834-18834/com.example.muhammadobaid.sims E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3012)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1716)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:232)
at android.app.ActivityThread.main(ActivityThread.java:6802)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
**Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #19: <item> tag requires a 'drawable' attribute or child tag defining a drawable
at** android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:183)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:116)
at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1232)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1205)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:998)
... 44 more
Caused by: android.content.res.Resources$NotFoundException: Drawable
android:color/highlighted_text_material with resource ID #0x1060118
That's a NotFoundException which means it couldn't find such color-file anything in this path:
res/color/highlighted_text_material.xml
You should probably change this.
Also, I just saw that there is another issue with the Spinner:
Caused by: android.view.InflateException: Binary XML file line #98: Binary XML file line #98: Error inflating class Spinner
I'm suspecting about this part:
android:popupBackground="?android:attr/textColorHighlightInverse"
Try changing the color to a not private resource.
The another issue is:
<item> tag requires a 'drawable' attribute or child tag defining a drawable
Add what it says to your drawable file: requires a 'drawable' attribute or child tag defining a drawable
I get this error:
android.view.InflateException: Binary XML file line #149: Binary XML file line #149: Error inflating class android.support.design.widget.FloatingActionButton
I know there is a duplicate question, but the answers there do not solve my issue.
This is my build.gradle(app)
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 21
targetSdkVersion 26
versionCode 14
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v13:26.1.0'
implementation "com.android.support:support-fragment:26.1.0"
On the other duplicate question, the answer asked to downgrade the sdkVersion to 25. I tried that, but it broke my whole app. I need to add a lot of extra codes here and there, and remove certain features (notification channel for example) to make it compatible with SDK 25.
Is there anyway around this?
My FAB XML Code:
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_addnew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:backgroundTint="#color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="#drawable/ic_add_white_24px"
/>
Edit: Added on full log cat:
09-25 16:20:52.250 5637-5637/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.xxx, PID: 5637
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.xxx/com.xxx.xxx.OrderActivity}: android.view.InflateException: Binary XML file line #149: Binary XML file line #149: Error inflating class android.support.design.widget.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
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 #149: Binary XML file line #149: Error inflating class android.support.design.widget.FloatingActionButton
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.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.xxx.xxx.OrderActivity.onCreate(OrderActivity.java:72)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
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)
Edit: Added the rest of XML file as requested.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/ConstraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E0E0E0"
tools:context="com.xxx.xxx.OrderActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/header"
app:layout_constraintLeft_toLeftOf="#+id/ConstraintLayout"
app:layout_constraintRight_toRightOf="#+id/ConstraintLayout"
app:layout_constraintTop_toTopOf="#+id/ConstraintLayout"
android:background="#color/white"
>
<ImageView
android:id="#+id/icon"
style="#style/ThemeOverlay.Logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/white"
android:contentDescription="#string/icon"
android:src="#drawable/local_icon"
app:layout_constraintLeft_toLeftOf="#+id/header"
app:layout_constraintTop_toTopOf="#+id/header"
app:layout_constraintBottom_toBottomOf="#+id/header"
android:layout_marginTop="#dimen/border_margin"
android:layout_marginStart="#dimen/border_margin"
android:layout_marginBottom="#dimen/border_margin"
/>
<TextView
android:id="#+id/org_ID"
style="#style/AppTheme.Subheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
tools:text="ABCD"
android:visibility="visible"
android:layout_marginStart="#dimen/border_margin"
android:layout_marginTop="#dimen/half_border_margin"
app:layout_constraintLeft_toRightOf="#+id/icon"
app:layout_constraintTop_toTopOf="#+id/header"
/>
<TextView
android:id="#+id/user_ID"
style="#style/AppTheme.Subsubheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="35"
android:lines="1"
tools:text="abc123#gmail.com"
android:visibility="visible"
android:layout_marginStart="#dimen/border_margin"
app:layout_constraintLeft_toRightOf="#+id/icon"
app:layout_constraintTop_toBottomOf="#+id/org_ID"/>
<TextView
android:id="#+id/version"
style="#style/AppTheme.Subsubsubheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="30"
android:lines="1"
android:visibility="visible"
android:layout_marginStart="#dimen/border_margin"
app:layout_constraintLeft_toRightOf="#+id/icon"
app:layout_constraintTop_toBottomOf="#+id/user_ID"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_more_vert_black_24dp"
android:contentDescription="#string/desc_overflow_button"
android:onClick="showPopup"
app:layout_constraintTop_toTopOf="#+id/header"
app:layout_constraintBottom_toBottomOf="#+id/header"
app:layout_constraintRight_toRightOf="#+id/header"
android:background="#android:color/transparent"
android:layout_marginEnd="#dimen/border_margin2"
/>
</android.support.constraint.ConstraintLayout>
<TextView
android:id="#+id/order_ID"
style="#style/AppTheme.Subheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:text="#string/store"
android:visibility="visible"
android:layout_marginStart="#dimen/double_border_margin"
app:layout_constraintBottom_toTopOf="#+id/recycler_orders"
app:layout_constraintLeft_toLeftOf="#+id/ConstraintLayout"
app:layout_constraintTop_toBottomOf="#+id/header" />
<Spinner
android:id="#+id/storespinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/recycler_orders"
app:layout_constraintLeft_toRightOf="#+id/order_ID"
app:layout_constraintTop_toBottomOf="#+id/header"
app:layout_constraintRight_toRightOf="#+id/ConstraintLayout"
android:visibility="visible"
android:layout_marginStart="0dp"
>
</Spinner>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_orders"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#color/white"
app:layout_constraintBottom_toBottomOf="#+id/ConstraintLayout"
app:layout_constraintLeft_toLeftOf="#+id/ConstraintLayout"
app:layout_constraintRight_toRightOf="#+id/ConstraintLayout"
app:layout_constraintTop_toBottomOf="#+id/order_ID"
tools:listitem="#layout/item_orders" />
<ProgressBar
android:id="#+id/progress_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/recycler_orders"
android:layout_alignTop="#+id/recycler_orders"
android:layout_centerHorizontal="true"
android:visibility="gone" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_addnew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:backgroundTint="#color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="#drawable/ic_add_white_24px"
/>
</android.support.constraint.ConstraintLayout>
Edit: Add on styles.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
I've solved the issue. I found that
app:srcCompat="#drawable/ic_add_white_24px"
from my XML, the drawable file was in the v24 folder, that's what causing the error.
(stupid me)
Hi i have some error when running my application. I have a java files that calls a xml file to inflate a fragment. However when i run it i have an inflationexception. I have looked around but non of the solution seems to work for me. The code is able to run smoothly on emulators and some real devices but when i try to run it on my S3 the error is shown. I my java and xml files are shown below
LoginFragment.java
package com.example.ray.cdmsv2.Fragments;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.ray.cdmsv2.R;
public class LoginFragment extends Fragment {
#Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup container, Bundle savedInstanceState) {
return layoutInflater.inflate(R.layout.fragment_login,container,false);
}
}
fragment_login.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context=".Fragments.LoginFragment"
android:background="#color/white">
<LinearLayout
android:id="#+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
<!-- Logo -->
<TableRow
android:layout_gravity="center">
<!-- Spacer -->
<TextView
android:layout_weight="10"/>
<ImageView
android:id="#+id/imageViewFrontLogo"
android:layout_width="200dp"
android:layout_height="235dp"
android:src="#drawable/logo_simtech"
android:layout_weight="80"/>
<!-- Spacer -->
<TextView
android:layout_weight="10"/>
</TableRow>
</TableLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="#+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_username"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true"
android:layout_marginTop="0dp"
android:layout_marginBottom="10dp"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_password"
android:imeActionId="#+id/login"
android:imeActionLabel="#string/action_login"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="#+id/forgot_password_link"
style="#style/Blue_Font"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/forgot_password"
android:maxLines="1"
android:singleLine="true"
android:gravity="center"
android:clickable="true"
android:onClick="actionForgotPassword"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"/>
<Button
android:id="#+id/sign_in_button"
style="#style/Button_Background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/action_login_short"
android:textStyle="bold"
android:onClick="actionLogin"
android:layout_margin="5dp"/>
</LinearLayout>
My LoginFragment.java is the file that is trying to inflate the fragment_login however when i try to run the code i have the following error shown
03-05 16:14:26.752 21537-21537/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ray.cdmsv2, PID: 21537
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ray.cdmsv2/com.example.ray.cdmsv2.Activities.MainActivity}: android.view.InflateException: Binary XML file line #53: Error inflating class android.support.design.widget.TextInputLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2702)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class android.support.design.widget.TextInputLayout
at android.view.LayoutInflater.createView(LayoutInflater.java:640)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at com.example.ray.cdmsv2.Fragments.LoginFragment.onCreateView(LoginFragment.java:16)
at android.app.Fragment.performCreateView(Fragment.java:2114)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:904)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
at android.app.BackStackRecord.run(BackStackRecord.java:833)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
at android.app.Activity.performStart(Activity.java:6328)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
Help will be much appreciated