So around 1% of my daily users are haunted with the NavigationView exception which is caused by an image resource not being found. I find that strange, 99% of other users are just fine. I was hoping that updating my dependancies in version iterations will resolve the issue itself, but unfortunately, this error has stayed in my Crashlytics logs for 6 iterations already and it's the worst crash that is affecting my users.
The obvious thing would be that it is specific to older devices, but this would be a wrong assumption. It is not device specific, neither version specific. Although some specifics can be pointed out
Android Version
90% Andorid 8
10% Android 7
Device
Huawei 50%
Samsung 50%
Two relevant dependancies i'm using:
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
The relevant piece of code in the XML layout:
<com.google.android.material.navigation.NavigationView
android:id="#+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:theme="#style/ThemeOverlay.AppCompat.Light"
app:headerLayout="#layout/layout_drawer_header2"
app:menu="#menu/navigation" />
The Header layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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/authWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
android:orientation="vertical"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
tools:layout_width="240dp">
<TextView
android:id="#+id/number"
style="#style/Base.TextAppearance.AppCompat.Display3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:fontFamily="sans-serif-medium"
android:textColor="?android:textColorPrimary"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="#+id/car"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/driver"
tools:text="#01" />
<ImageView
android:id="#+id/driverIcon"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
app:layout_constraintBottom_toBottomOf="#+id/driver"
app:layout_constraintStart_toEndOf="#+id/number"
app:layout_constraintTop_toTopOf="#+id/driver"
app:srcCompat="#drawable/ic_person_white_24dp" />
<TextView
android:id="#+id/driver"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="2dp"
android:layout_marginTop="16dp"
android:drawablePadding="8dp"
android:ellipsize="end"
android:lines="1"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Body1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/driverIcon"
app:layout_constraintTop_toTopOf="parent"
tools:text="Drivers name" />
<ImageView
android:id="#+id/coDriverIcon"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
app:layout_constraintBottom_toBottomOf="#+id/codriver"
app:layout_constraintStart_toEndOf="#+id/number"
app:layout_constraintTop_toTopOf="#+id/codriver"
app:srcCompat="#drawable/ic_person_white_24dp" />
<TextView
android:id="#+id/codriver"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="2dp"
android:drawablePadding="8dp"
android:ellipsize="end"
android:lines="1"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Body1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/coDriverIcon"
app:layout_constraintTop_toBottomOf="#+id/driver"
tools:text="Co-Driver name" />
<ImageView
android:id="#+id/carIcon"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
app:layout_constraintBottom_toBottomOf="#+id/car"
app:layout_constraintStart_toEndOf="#+id/number"
app:layout_constraintTop_toTopOf="#+id/car"
app:srcCompat="#drawable/ic_car_white_24dp" />
<TextView
android:id="#+id/car"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="2dp"
android:ellipsize="end"
android:lines="1"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Body1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/carIcon"
app:layout_constraintTop_toBottomOf="#+id/codriver"
tools:text="Racing Car" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<ImageView
android:id="#+id/image"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:srcCompat="#drawable/ic_account_circle_white_24dp" />
<ImageView
android:id="#+id/logout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:padding="12dp"
android:tint="#android:color/white"
app:srcCompat="#drawable/ic_log_out" />
</RelativeLayout>
<TextView
android:id="#+id/switchText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginRight="8dp"
android:autoLink="web"
android:gravity="center_vertical"
android:maxLines="2"
android:text="#string/track_me_on_racelivemaps_com"
app:layout_constraintEnd_toStartOf="#+id/trackingOn"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/number" />
<Switch
android:layout_width="wrap_content"
android:id="#+id/trackingOn"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_height="wrap_content"
android:padding="8dp"
android:autoLink="web"
android:gravity="center_vertical"
android:maxLines="2"
app:layout_constraintBottom_toBottomOf="#+id/switchText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/switchText" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:text="#string/active_stage"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Body2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/switchText" />
<Spinner
android:id="#+id/activeStage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView12" />
</androidx.constraintlayout.widget.ConstraintLayout>
The menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="#string/mode">
<menu>
<group android:checkableBehavior="single">
<item
android:id="#+id/recce"
android:icon="#drawable/ic_write_black_24dp"
android:title="#string/reccemode" />
<item
android:id="#+id/liaison"
android:icon="#drawable/ic_route_black_24dp"
android:title="#string/liaisonmode" />
<item
android:id="#+id/racing"
android:icon="#drawable/ic_racing_flag_black_24dp"
android:title="#string/racemode" />
<item
android:id="#+id/tsd"
android:icon="#drawable/ic_timer_black_24dp"
android:title="#string/tsd" />
<item
android:id="#+id/tsd_advanced"
android:icon="#drawable/ic_tsd_advanced"
android:title="#string/tsd_advanced" />
<item
android:id="#+id/custom_1"
android:icon="#drawable/ic_navigation_layout"
android:title="#string/custom_layout_1" />
<item
android:id="#+id/custom_2"
android:icon="#drawable/ic_navigation_layout"
android:title="#string/custom_layout_2" />
<item
android:id="#+id/custom_3"
android:icon="#drawable/ic_navigation_layout"
android:title="#string/custom_layout_3" />
</group>
</menu>
</item>
<group android:checkableBehavior="none">
<item
android:id="#+id/stages"
android:icon="#drawable/ic_stage_black_24dp"
android:title="#string/special_stages" />
<item
android:id="#+id/settings"
android:icon="#drawable/ic_settings_black_24dp"
android:title="#string/settings" />
<item
android:id="#+id/customize_ui"
android:icon="#drawable/ic_layout_edit"
android:title="#string/customize_ui" />
<item
android:id="#+id/weather"
android:icon="#drawable/ic_weather"
android:title="#string/weather" />
<item
android:id="#+id/login"
android:icon="#drawable/ic_key_white_24dp"
android:title="#string/log_in" />
<item
android:id="#+id/manual"
android:icon="#drawable/ic_manual"
android:title="#string/user_manual" />
<item
android:id="#+id/language"
android:icon="#drawable/ic_translate"
android:title="#string/language" />
<item
android:id="#+id/invite"
android:icon="#drawable/ic_share_black_24dp"
android:title="#string/invite" />
<item
android:id="#+id/feedback"
android:icon="#drawable/ic_feedback_black_24dp"
android:title="#string/feedback_report_bug" />
<item
android:id="#+id/tester"
android:icon="#drawable/ic_tester"
android:title="#string/become_a_tester" />
<item
android:id="#+id/policy"
android:icon="#drawable/ic_policy"
android:title="#string/privacy_policy" />
<item
android:id="#+id/logoff"
android:icon="#drawable/ic_key_white_24dp"
android:title="#string/log_off" />
<item
android:id="#+id/exit"
android:icon="#drawable/ic_exit_to_app_black_24dp"
android:title="#string/exit" />
</group>
</menu>
And finally the crash logs.
android.view.InflateException: Binary XML file line #48: Binary XML
file line #48: Error inflating class
com.google.android.material.navigation.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3173)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3284)
at android.app.ActivityThread.-wrap12(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1894)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7383)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
Caused by android.view.InflateException: Binary XML file line #48:
Binary XML file line #48: Error inflating class
com.google.android.material.navigation.NavigationView
Caused by android.view.InflateException: Binary XML file line #48:
Error inflating class
com.google.android.material.navigation.NavigationView
Caused by java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:658)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:801)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at ee.siimplangi.rallytripmeter.activities.MainActivity.onCreate(MainActivity.kt:186)
at android.app.Activity.performCreate(Activity.java:7358)
at android.app.Activity.performCreate(Activity.java:7349)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1219)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3126)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3284)
at android.app.ActivityThread.-wrap12(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1894)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7383)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
Caused by android.view.InflateException: Binary XML file line #29:
Binary XML file line #29: Error inflating class ImageView
Caused by android.view.InflateException: Binary XML file line #29:
Error inflating class ImageView
Caused by android.content.res.Resources$NotFoundException: Resource ID
0x7f0800a5
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:290)
at android.content.res.Resources.getValue(Resources.java:1476)
at androidx.appcompat.widget.AppCompatDrawableManager.createDrawableIfNeeded(AppCompatDrawableManager.java:235)
at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:200)
at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:102)
at androidx.appcompat.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:59)
at androidx.appcompat.widget.AppCompatImageView.(AppCompatImageView.java:78)
at androidx.appcompat.widget.AppCompatImageView.(AppCompatImageView.java:68)
at androidx.appcompat.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:182)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:783)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.google.android.material.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:207)
at com.google.android.material.navigation.NavigationView.inflateHeaderView(NavigationView.java:281)
at com.google.android.material.navigation.NavigationView.(NavigationView.java:193)
at com.google.android.material.navigation.NavigationView.(NavigationView.java:104)
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:658)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:801)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at ee.siimplangi.rallytripmeter.activities.MainActivity.onCreate(MainActivity.kt:186)
at android.app.Activity.performCreate(Activity.java:7358)
at android.app.Activity.performCreate(Activity.java:7349)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1219)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3126)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3284)
at android.app.ActivityThread.-wrap12(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1894)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7383)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
after reading the comments , first of all you have to use android:src because you are not using vector drawable.
This problem occur when we paste image from explorer to drawable folder then it ask whether to copy drawable or drawable-v24 and if you have pasted images in both directory structures, or have one more images with different directory structure then it will show this error, make sure to delete the icon from drawable-v24 after moving it to drawable folder , and clean the project and then run it will work .
Related
First of all, I know that Material Components 1.1.0 is still in alpha and I am aware, that it can be unstable, but I am interested in some solution. It still could be some problem in my code.
I am creating Alert Dialog with custom view and it is just crashing with such logs. It is working perfectly on some devices and just crashing on other.
android.content.res.Resources$NotFoundException: File res/drawable-v21/abc_dialog_material_background.xml from color state list resource ID #0x7f080019
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2750)
at android.content.res.Resources.loadColorStateList(Resources.java:2699)
at android.content.res.TypedArray.getColor(TypedArray.java:439)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:3780)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:3981)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:1969)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:699)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:641)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:535)
at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
at androidx.appcompat.app.AlertController.installContent(AlertController.java:232)
at androidx.appcompat.app.AlertDialog.onCreate(AlertDialog.java:279)
at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
at android.app.Dialog.show(Dialog.java:295)
at com.itemstudio.castro.services.dialogs.DialogsHelper.openScreenTesterSettingsDialog(DialogsHelper.kt:168)
at com.itemstudio.castro.screens.tools.screen_tester_activity.ScreenTesterView$initClickListeners$1.onClick(ScreenTesterView.kt:25)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid color state list tag inset
at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:217)
at android.content.res.ColorStateList.createFromXml(ColorStateList.java:201)
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2746)
at android.content.res.Resources.loadColorStateList(Resources.java:2699)
at android.content.res.TypedArray.getColor(TypedArray.java:439)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:3780)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:3981)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:1969)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:699)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:641)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:535)
at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
at androidx.appcompat.app.AlertController.installContent(AlertController.java:232)
at androidx.appcompat.app.AlertDialog.onCreate(AlertDialog.java:279)
at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
at android.app.Dialog.show(Dialog.java:295)
at com.itemstudio.castro.services.dialogs.DialogsHelper.openScreenTesterSettingsDialog(DialogsHelper.kt:168)
at com.itemstudio.castro.screens.tools.screen_tester_activity.ScreenTesterView$initClickListeners$1.onClick(ScreenTesterView.kt:25)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Here is my XML.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="24dp"
android:background="?attr/colorBackgroundSecondary"
android:paddingTop="24dp"
android:paddingEnd="24dp"
android:paddingBottom="8dp">
<TextView
android:id="#+id/screenTesterOptionsLayoutTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:fontFamily="sans-serif-medium"
android:text="#string/screen_tester_dialog_title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="20sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="vertical">
<Switch
android:id="#+id/screenTesterOptionsDifferentColors"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_different_colors" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<Switch
android:id="#+id/screenTesterOptionsCoordinates"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_coordinates" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<Switch
android:id="#+id/screenTesterOptionsLines"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_lines" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<Switch
android:id="#+id/screenTesterOptionsVibration"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration" />
<View
android:id="#+id/screenTesterOptionsVibrationIntensityDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<TextView
android:id="#+id/screenTesterOptionsVibrationIntensityTitle"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:text="#string/screen_tester_dialog_vibration_intensity"
android:textColor="?android:attr/textColorPrimary" />
<RadioGroup
android:id="#+id/screenTesterOptionsVibrationIntensitySelection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp">
<RadioButton
android:id="#+id/screenTesterOptionsVibrationIntensityLow"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration_intensity_low"
android:textColor="?android:attr/textColorSecondary" />
<RadioButton
android:id="#+id/screenTesterOptionsVibrationIntensityMedium"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration_intensity_medium"
android:textColor="?android:attr/textColorSecondary" />
<RadioButton
android:id="#+id/screenTesterOptionsVibrationIntensityHigh"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration_intensity_high"
android:textColor="?android:attr/textColorSecondary" />
</RadioGroup>
<com.google.android.material.button.MaterialButton
android:id="#+id/screenTesterOptionsLayoutButtonApply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="8dp"
android:text="#string/screen_tester_dialog_action_apply"
android:textColor="?attr/colorAccent" />
</LinearLayout>
</ScrollView>
If you think, that it is some bug in framework I will just open issue in Google's issue tracker.
The only solution that i found for now is to supercharge the dialog theme overlay :
<style name="Theme.App" parent="Theme.MaterialComponents.Light.NoActionBar" />
<item name="materialAlertDialogTheme">#style/ThemeOverlay.App.MaterialAlertDialog</item>
</style>
<style name="ThemeOverlay.App.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="android:windowBackground">#color/white</item>
</style>
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)
The following XML file will be inflated and I don't know why I'm getting an error. Here is the XML file:
<?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:fresco="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:paddingLeft="20dp"
android:paddingRight="20dp">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/overseas_broker_sell_avatar"
android:layout_width="108dp"
android:layout_height="108dp"
android:layout_marginTop="15dp"
android:contentDescription="#null"
app:layout_constraintStart_toStartOf="parent"
fresco:actualImageScaleType="centerCrop" />
<TextView
android:id="#+id/overseas_broker_sell_company_title"
style="#style/overseasAgentTitle"
android:layout_width="wrap_content"
android:layout_height="15dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:text="海外代理公司"
app:layout_constraintStart_toEndOf="#+id/overseas_broker_sell_avatar"
app:layout_constraintTop_toTopOf="#+id/overseas_broker_sell_avatar" />
<TextView
android:id="#+id/overseas_broker_sell_company_value"
style="#style/overseasAgentDescribe"
android:layout_width="0dp"
android:layout_height="15dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/overseas_broker_sell_company_title"
app:layout_constraintTop_toBottomOf="#+id/overseas_broker_sell_company_title"
tools:text="Philippine Boracay Blue Water111111111" />
<TextView
android:id="#+id/overseas_broker_sell_presenter_title"
style="#style/overseasAgentTitle"
android:layout_width="wrap_content"
android:layout_height="15dp"
android:text="海外置业代表"
app:layout_constraintStart_toStartOf="#+id/overseas_broker_sell_company_value"
app:layout_constraintTop_toBottomOf="#+id/overseas_broker_sell_company_value" />
<TextView
android:id="#+id/overseas_broker_sell_presenter_value"
style="#style/overseasAgentDescribe"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:width="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/overseas_broker_sell_presenter_title"
app:layout_constraintTop_toBottomOf="#+id/overseas_broker_sell_presenter_title"
tools:text="AddressAddressAddressAddressAddressAddress" />
<TextView
android:id="#+id/overseas_broker_sell_phone_title"
style="#style/overseasAgentTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="海外代理电话"
app:layout_constraintStart_toStartOf="#+id/overseas_broker_sell_presenter_value"
app:layout_constraintTop_toBottomOf="#+id/overseas_broker_sell_presenter_value" />
<TextView
android:id="#+id/overseas_broker_sell_phone_value"
style="#style/overseasAgentDescribe"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/overseas_broker_sell_phone_title"
app:layout_constraintTop_toBottomOf="#+id/overseas_broker_sell_phone_title"
tools:text="+39 714809471480947007148094700700" />
</android.support.constraint.ConstraintLayout>
Here is the logcat error.
line #31: You must supply a layout_width attribute.
Caused by: java.lang.UnsupportedOperationException: Binary XML file line #31: You must supply a layout_width attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:767)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:7245)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7427)
at android.support.constraint.ConstraintLayout$LayoutParams.<init>(ConstraintLayout.java:2102)
at android.support.constraint.ConstraintLayout.generateLayoutParams(ConstraintLayout.java:1536)
at android.support.constraint.ConstraintLayout.generateLayoutParams(ConstraintLayout.java:449)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:860)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
I am sure that it is this constraintLayout that's causing the problem, because #31 the line number indicated in the error is exactly the line where this textView layout_width is declared; the textView layout_width is there, so what is it complaining about? is there some other reason for constrainLayout ?
Thanks in advance!
do this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="expandableItemStyle">#style/ExpandableItemStyle</item>
</style>
<style name="ExpandableItemStyle">
<item name="android:layout_height">#dimen/item_size</item>
<item name="android:layout_width">#dimen/item_size</item>
<item name="android:background">#drawable/bg_item_with_title</item>
<item name="android:layout_margin">#dimen/item_margin</item>
<item name="android:textColor">#color/gray</item>
<item name="android:textSize">#dimen/item_text_size</item>
</style>
it helps you
I using the TextInputLayout UI mechanism in my login page of the application, everything works great except for device that run the 4.4.2 android version on this devices I have an exception.
This is my layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include android:id="#+id/loginInfiLogoRL"
layout="#layout/login_infi_logo_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="-3dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"/>
<!--EMAIL-->
<android.support.design.widget.TextInputLayout
android:id="#+id/email_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/loginInfiLogoRL"
android:theme="#style/TextLabel">
<EditText
android:id="#+id/etUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/login_screen_email_hint"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLines="1"
android:nextFocusDown="#+id/etPassword"
android:singleLine="true"
android:textColor="#android:color/white"
android:textColorHighlight="#color/Orange"
android:textColorHint="#android:color/white" />
</android.support.design.widget.TextInputLayout>
<RelativeLayout
android:id="#+id/rlPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_below="#id/email_wrapper">
<!--PASSWORD-->
<android.support.design.widget.TextInputLayout
android:id="#+id/password_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/TextLabel">
<EditText
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/login_screen_password_hint"
android:imeOptions="actionNext"
android:inputType="textPassword"
android:maxLines="1"
android:nextFocusDown="#+id/bSignIn"
android:shadowColor="#color/Orange"
android:singleLine="true"
android:textColor="#android:color/white"
android:textColorHint="#android:color/white" />
</android.support.design.widget.TextInputLayout>
<!--FORGOT-->
<TextView
android:id="#+id/tvForgotPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:paddingBottom="14dp"
android:paddingRight="10dp"
android:text="#string/login_screen_forgot_password_text"
android:textColor="#color/Orange"
android:textSize="16sp" />
</RelativeLayout>
<TextView
android:id="#+id/tvRememberMe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" />
<!--Buttons Login and SignUp-->
<LinearLayout
android:id="#+id/llSignUp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:layout_below="#+id/rlPassword">
<!--Sign up Button-->
<TextView
android:id="#+id/bSignUp"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:textSize="18sp"
android:gravity="center"
android:imeOptions="actionGo"
android:text="#string/login_screen_sign_up_button_text"
android:textColor="#color/Orange" />
<!--Login Button-->
<Button
android:id="#+id/bSignIn"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginLeft="16dp"
android:layout_weight="1"
android:background="#drawable/fragment_first_use_cloud_get_started_button_background"
android:focusable="true"
android:imeOptions="actionGo"
android:text="#string/login_screen_sign_in_button_text"
android:textColor="#color/Orange" />
</LinearLayout>
<LinearLayout
android:id="#+id/llFacebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/llSignUp"
android:gravity="right">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="8dp"
android:gravity="center"
android:text="#string/log_in_with_facebook"
android:textAppearance="#style/TextAppearance.AppCompat.Small.Inverse"
android:textColor="#android:color/white" />
<com.facebook.login.widget.LoginButton
android:id="#+id/bFacebookLogin"
android:layout_width="#dimen/circular_images_size_l"
android:layout_height="#dimen/circular_images_size_l"
android:background="#drawable/btnfbconnect"
android:text=""
android:textColor="#android:color/white"/>
</LinearLayout>
<!--Privacy-->
<ImageView
android:id="#+id/ivLockImage"
android:layout_width="#dimen/circular_images_size_l"
android:layout_height="#dimen/circular_images_size_l"
android:layout_alignParentLeft="true"
android:layout_below="#id/llFacebook"
android:layout_marginTop="18dp"
android:src="#drawable/iconshieldprivacy" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/llSignUp"
android:layout_alignParentRight="#+id/ivLockImage"
android:layout_alignRight="#+id/llSignUp"
android:layout_alignTop="#+id/ivLockImage"
android:layout_toRightOf="#+id/ivLockImage"
android:text="#string/login_screen_infi_privacy_title"
android:textColor="#android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/text1"
android:layout_width="241dp"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/textView2"
android:layout_alignRight="#+id/textView2"
android:layout_below="#+id/textView2"
android:layout_toRightOf="#+id/ivLockImage"
android:paddingTop="3dp"
android:text="#string/login_screen_infi_privacy_description"
android:textColor="#android:color/white"
android:textSize="10sp" />
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:layout_alignStart="#+id/text1"
android:layout_alignLeft="#+id/text1"
android:layout_below="#+id/text1"
android:layout_alignParentBottom="true" />
</RelativeLayout>
UPDATE: This is the style xml:
<style name="TextLabel" parent="TextAppearance.AppCompat">
<!-- Hint color and label color in FALSE state -->
<item name="android:textColorHint">#android:color/white</item>
<item name="android:textColorHighlight">#android:color/white</item>
<item name="android:textColorLink">#android:color/white</item>
<item name="android:textSize">20sp</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name="colorAccent">#color/accent</item>
<item name="colorControlNormal">#android:color/white</item>
<item name="colorControlActivated">#color/accent</item>
</style>
This is the exception:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.infibond.infi/com.infibond.account.login.LoginActivity}: android.view.InflateException: Binary XML file line #22: Error inflating class EditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2281)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5230)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:780)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:596)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by android.view.InflateException: Binary XML file line #22: Error inflating class EditText
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.infibond.account.login.LoginFragment.onCreateView(LoginFragment.java:92)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
at com.infibond.base.Inheritance.Activities.ActivityBase.onStart(ActivityBase.java:112)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5421)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2242)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5230)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:780)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:596)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
at android.content.res.TypedArray.getColor(TypedArray.java:327)
at android.widget.TextView.<init>(TextView.java:703)
at android.widget.EditText.<init>(EditText.java:61)
at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:60)
at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:56)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:101)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:280)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:172)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.infibond.account.login.LoginFragment.onCreateView(LoginFragment.java:92)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
at com.infibond.base.Inheritance.Activities.ActivityBase.onStart(ActivityBase.java:112)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5421)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2242)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5230)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:780)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:596)
at dalvik.system.NativeStart.main(NativeStart.java)
Why does this happen, and what is the proper way to fix it?
What fixed this issue was removing the parent="TextAppearance.AppCompat" from the style configuration:
So now the style looks as follows:
<style name="TextLabel">
<!-- Hint color and label color in FALSE state -->
<item name="android:textColorHint">#color/White</item>
<item name="android:textColorHighlight">#android:color/white</item>
<item name="android:textColorLink">#color/White</item>
<item name="android:textSize">20sp</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name="colorAccent">#color/accent</item>
<item name="colorControlNormal">#android:color/white</item>
<item name="colorControlActivated">#color/accent</item>
</style>
And in the xml layout:
<android.support.design.widget.TextInputLayout
android:id="#+id/email_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/loginInfiLogoRL"
android:theme="#style/TextLabel">
<EditText
android:id="#+id/etUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/login_screen_email_hint"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLines="1"
android:nextFocusDown="#+id/etPassword"
android:singleLine="true"
android:textColor="#android:color/white"
android:textColorHighlight="#color/White"
android:textColorHint="#android:color/white" />
</android.support.design.widget.TextInputLayout>
Your problem is with another xml file. I think it's because one of your drawable files that you are using a color attribute in it.
read here for more information.