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>
Related
I'm trying to start this fragment but I'm taking the error below. From what I read, this seems to have a possible large image, but I didn't identify it, after all in this part it calls maps. If anyone has experienced this error, I am grateful for the contribution!`
2021-06-14 12:42:10.327 26833-26833/com.helpcars.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.helpcars.app, PID: 26833
android.view.InflateException: Binary XML file line #133: Binary XML file line #133: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #133: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.helpcars.app.Fragments.HomeFragment.onCreateView(HomeFragment.java:308)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.content.res.Resources$NotFoundException: Drawable android:color/primary_text_dark with resource ID #0x1060001
Caused by: android.content.res.Resources$NotFoundException: File res/color/primary_text_dark.xml from drawable resource ID #0x1060001
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:847)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:631)
at android.content.res.Resources.loadDrawable(Resources.java:897)
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:955)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.view.View.<init>(View.java:5010)
at android.view.ViewGroup.<init>(ViewGroup.java:659)
at android.widget.LinearLayout.<init>(LinearLayout.java:244)
at android.widget.LinearLayout.<init>(LinearLayout.java:240)
at android.widget.LinearLayout.<init>(LinearLayout.java:236)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
2021-06-14 12:42:10.331 26833-26833/com.helpcars.app E/AndroidRuntime: at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.helpcars.app.Fragments.HomeFragment.onCreateView(HomeFragment.java:308)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #18: <item> tag requires a 'drawable' attribute or child tag defining a drawable
at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:190)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:122)
at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)
at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1291)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:833)
... 42 more
This is the XML of the layout I'm trying to "Inflate".
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Map frame -->
<LinearLayout
android:id="#+id/mapLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/provider_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!--Project Flow-->
<!--Request to providers-->
<LinearLayout
android:id="#+id/lnrRequestProviders"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#android:color/white"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rcvServiceTypes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_marginTop="#dimen/_5sdp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/view_bg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/_10sdp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="#+id/imgPaymentType"
android:layout_width="#dimen/_20sdp"
android:layout_height="#dimen/_20sdp"
app:srcCompat="#drawable/money1" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblPaymentType"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/selected_payment_mode"
android:textColor="#android:color/black"
android:textSize="16sp" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblPaymentChange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="#string/change"
android:textColor="#android:color/holo_blue_dark"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<com.helpcars.app.Utils.MyButton
android:id="#+id/btnRequestRides"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="#dimen/_10sdp"
android:layout_marginLeft="#dimen/_20sdp"
android:layout_marginRight="#dimen/_20sdp"
android:layout_marginTop="#dimen/_10sdp"
android:background="#drawable/rounded_button"
android:text="#string/estimate"
android:textColor="#color/button_text_color" />
</LinearLayout>
<!-- Provider popup Layout-->
<LinearLayout
android:id="#+id/lnrProviderPopup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:id="#+id/lnrHidePopup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/transparent_black"
android:orientation="vertical"
android:visibility="gone">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#android:color/primary_text_dark"
android:gravity="center"
android:orientation="vertical"
android:padding="#dimen/_10sdp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imgProviderPopup"
android:layout_width="#dimen/_60sdp"
android:layout_height="#dimen/_60sdp"
android:layout_marginTop="#dimen/_5sdp"
android:src="#drawable/pickup_drop_icon" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblServiceName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_10sdp"
android:gravity="center"
android:maxLines="1"
android:text=""
android:textColor="#color/text_color_black"
android:textSize="#dimen/_14sdp" />
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_5sdp"
android:gravity="center"
android:maxLines="1"
android:text="Aguarde o reboque em um local seguro"
android:textColor="#color/text_color_black"
android:textSize="#dimen/_14sdp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginTop="#dimen/_10sdp"
android:background="#android:color/primary_text_dark"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:id="#+id/lnrPriceBase"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start"
android:maxLines="1"
android:text="Base Price"
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblBasePricePopup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end"
android:maxLines="1"
android:text=""
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
</LinearLayout>
<LinearLayout
android:id="#+id/lnrPricekm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:orientation="horizontal">
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start|center"
android:maxLines="1"
android:text="Price/km"
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblPriceKm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end"
android:maxLines="1"
android:text=""
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
</LinearLayout>
<LinearLayout
android:id="#+id/lnrPricemin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:orientation="horizontal">
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start|center"
android:maxLines="1"
android:text="Price/min"
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblPriceMin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end"
android:maxLines="1"
android:text=""
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
</LinearLayout>
<LinearLayout
android:id="#+id/lnrCalculationType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:orientation="horizontal">
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start|center"
android:maxLines="1"
android:text="- É obrigatório o acompanhamento do responsável"
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
</LinearLayout>
<LinearLayout
android:id="#+id/lnrCapacity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:orientation="horizontal">
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start|center"
android:maxLines="1"
android:text="- Para remoção, somente veículos descarregados"
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblCapacity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end"
android:maxLines="1"
android:text=""
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
</LinearLayout>
</LinearLayout>
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblProviderDesc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_15sdp"
android:layout_weight="1"
android:lineSpacingMultiplier="1.3"
android:text="The fare will be the price presented upon booking, or, if the journey changes, the fare will be based on the rates provided. Tap fare for details."
android:textSize="#dimen/_10sdp" />
</LinearLayout>
HomeFragment
#Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
if (rootView == null) {
rootView = inflater.inflate(R.layout.fragment_home, container, false);
}
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
init(rootView);
//permission to access location
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// Android M Permission check
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
} else {
initMap();
MapsInitializer.initialize(getActivity());
}
}
}, 500);
return rootView;
}
The detail is that it works for various devices and android versions, but specifically for the Moto G Android Pie I get this error.
The error is on the XML file line #133, but I couldn't understand why the LinearLayout starts there.
Possible solution based on the provided source code:
Check if you have used android:src instead of app:srcCompat to assign vector assets. Is #drawable/pickup_drop_icon a vector asset? If yes, you should NOT use android:src.
You forgot to place the trailing </LinearLayout> of the parent.
Add </LinearLayout> to the bottom of your code.
Try code folding the XML file, you will notice that it is missing a </LinearLayout> at the end.
when the compiler gives a generic error message Binary XML file line #133: Error inflating class, I recommend that you first identify if there are any errors in the XML file.
Let me know if you have any questions.
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
I encountered this error in android studio while learning it:
08-20 11:56:52.192 9815-9815/com.example.android.courtcountee1 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.courtcountee1, PID: 9815
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.courtcountee1/com.example.android.courtcountee1.MainActivity}: android.view.InflateException: Binary XML file line #66: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
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:7325)
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 #66: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
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.example.android.courtcountee1.MainActivity.onCreate(MainActivity.java:15)
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:7325)
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: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
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.example.android.courtcountee1.MainActivity.onCreate(MainActivity.java:15)
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:7325)
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)
The XML
i THINK THE VIEW TAG IS CAUSING THE PROBLEM AS REMOVING IT RESOLVED THIS
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:layout_weight="1"
android:orientation="vertical"
tools:context="com.example.android.courtcounter.MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="Team A" />
<TextView
android:id="#+id/team_a_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:fontFamily="sans-serif-light"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="0"
android:textColor="#000000"
android:textSize="56dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="threePoints"
android:text="+3 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="twoPoints"
android:text="+2 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="freeThrow"
android:text="Free Throw" />
</LinearLayout>
<!--<view
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:background="#android:color/darker_gray">
</view>-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="24dp"
android:layout_weight="1"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="Team B"
android:textColor="#616161"
android:textSize="14sp" />
<TextView
android:id="#+id/team_b_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:fontFamily="sans-serif-light"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="0"
android:textColor="#000000"
android:textSize="56dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="threePointsB"
android:text="+3 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="twoPointsB"
android:text="+2 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="freeThrowB"
android:text="Free Throw" />
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="32dp"
android:onClick="reset"
android:text="RESET" />
</RelativeLayout>
View tag must start with the capital letter, like this:
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:background="#android:color/darker_gray">
</View>
In fact,Every xml View tag will through the LayoutInflater class construct a real View class. About LayoutInflater, It will combine the xml tag with the View class in package android.view.、android.widget、android.webkit、android.app. About you use the view tag, you should use like this.
<view
android:id="#+id/test"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
class="androidx.constraintlayout.utils.widget.ImageFilterView"
android:background="#color/colorAccent"
/>
you must appoint the target class. because the LayoutInflater tell us should do.
View createViewFromTag(View parent, String name, Context context, AttributeSet attrs,
boolean ignoreThemeAttr) {
if (name.equals("view")) {
name = attrs.getAttributeValue(null, "class");
}
// Apply a theme wrapper, if allowed and one is specified.
if (!ignoreThemeAttr) {
final TypedArray ta = context.obtainStyledAttributes(attrs, ATTRS_THEME);
final int themeResId = ta.getResourceId(0, 0);
if (themeResId != 0) {
context = new ContextThemeWrapper(context, themeResId);
}
ta.recycle();
}
if (name.equals(TAG_1995)) {
// Let's party like it's 1995!
return new BlinkLayout(context, attrs);
}
...
because you not appoint the class.It can not find the real class about it,So It cause the exception.
my app is suffering from crash whenever i press back key. basically i have 4 fragments but app crashes only when it comes back on my first fragment.
FATAL EXCEPTION: main
Process: , PID: 5835
android.view.InflateException: Binary XML file line #16: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:770)
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 NewBookingFragment.onCreateView(NewBookingFragment.java:174)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.popFromBackStack(BackStackRecord.java:979)
at android.support.v4.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1670)
at android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:586)
at android.support.v4.app.FragmentActivity.onBackPressed(FragmentActivity.java:188)
at HomeActivity.onBackPressed(HomeActivity.java:161)
at android.app.Activity.onKeyUp(Activity.java:2576)
at android.view.KeyEvent.dispatch(KeyEvent.java:3171)
at android.app.Activity.dispatchKeyEvent(Activity.java:2831)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:534)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:241)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2429)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4580)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4535)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4070)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4123)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4199)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4097)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4256)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4070)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4123)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4097)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4070)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4123)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4232)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4419)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2480)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2074)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2065)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2457)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:143)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
Code-
#Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);//line 161
} else {
super.onBackPressed();
}
}
XML Code which is causing issue:
<RelativeLayout 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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.app.myapp.HomeActivity"
>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
class="com.app.myapp.TouchableSupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<RelativeLayout
android:id="#+id/rlDriverProgress"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:background="#drawable/oval_progress"
android:padding="5dp"
>
<ProgressBar
android:id="#+id/getDriversProgress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlTimeRequired"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:background="#drawable/oval_progress"
android:padding="5dp"
android:gravity="center|center_vertical|center_horizontal"
>
<TextView
android:layout_width="25dp"
android:layout_height="wrap_content"
android:text="10"
android:textStyle="bold"
android:textSize="17sp"
android:gravity="center|center_horizontal|center_vertical"
android:textColor="#color/colorWhite"
android:id="#+id/tvNoOfMins"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MIN"
android:textStyle="bold"
android:textSize="15sp"
android:textColor="#color/colorWhite"
android:id="#+id/tvMinsHeading"
android:layout_below="#+id/tvNoOfMins"
/>
</RelativeLayout>
<LinearLayout
android:id="#+id/llSearchBar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="center_horizontal|top"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="100dp"
android:background="#drawable/bg_search_bar"
android:orientation="horizontal">
<ImageView
android:id="#+id/icSelectPickup"
android:layout_width="45dp"
android:layout_height="23dp"
android:layout_gravity="center"
android:src="#drawable/icon_search"
/>
<EditText
android:id="#+id/tvPickupAddress"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#null"
android:editable="false"
android:elegantTextHeight="false"
android:enabled="true"
android:focusable="true"
android:focusableInTouchMode="false"
android:text="Select Pickup Address"
android:textAlignment="gravity"
android:gravity="center_vertical|center_horizontal"
android:textSize="16sp"
android:textStyle="normal" />
</LinearLayout>
<!--android:textColor="#color/whiteTranparent" -->
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:text="faisal"
android:id="#+id/dummyCenterTV"
/>
<ImageView
android:id="#+id/pickupLocationPin"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/dummyCenterTV"
android:src="#drawable/carpin" />
<LinearLayout
android:id="#+id/layoutBookButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:orientation="vertical"
android:layout_alignParentBottom="true"
>
<Button
android:id="#+id/btnPickLater"
android:layout_width="100dp"
android:layout_height="30dp"
android:text="Book Later"
android:layout_gravity="right|bottom"
android:layout_marginBottom="3dp"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:textSize="11dp"
android:background="#drawable/rc_primary_button"
android:textColor="#color/colorWhite"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/label_pick_now"
android:textAllCaps="false"
android:id="#+id/btnPickNow"
android:background="#color/colorAccent"
android:textColor="#color/colorWhite"
android:textSize="18dp"
android:textStyle="bold"
android:focusable="true"
android:clickable="true"
/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
i think map fragment section is the part crashing app. please have a look
Your error occurs here:
com.app.minicabscouk.HomeActivity.onBackPressed(HomeActivity.java:161)
That's line 161 of your HomeActivity. You'll need to post the code from that class if you still can't figure it out yourself.
Hey, turns out I made a mistake! Disregard my above answer, sorry.
Check out the first line here:
FATAL EXCEPTION: main Process: , PID: 5835 android.view.InflateException: Binary XML file line #16: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:770)
That's your actual problem. Whichever fragment you're trying to create, there's a problem with the XML at line 16.
When i try to open my chat class , sometimes it runs properly , sometimes it gives OutOfMemoryError at setContentView line.I can't understand what is the cause of problem?
Here is my xml code :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbarmesajlasma"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#color/ColorPrimary"
android:elevation="1dp">
<RelativeLayout
android:id="#+id/layoutmesajlasma"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000">
<ImageButton
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_centerVertical="true"
android:background="#00000000"
android:longClickable="false"
android:src="#mipmap/geribas" />
<ImageButton
android:id="#+id/imageButton"
android:layout_width="43dp"
android:layout_height="43dp"
android:layout_marginLeft="35dp"
android:background="#00000000"
android:layout_centerVertical="true" />
<TextView
android:id="#+id/textView2"
android:layout_width="135dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="85dp"
android:text="Abdurrahman"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_centerVertical="true"
android:textColor="#ffffff"
android:textIsSelectable="false"
android:textSize="15dp"
android:textStyle="bold" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:layout_below="#+id/toolbarmesajlasma"
android:background="#mipmap/maybehi">
<ListView
android:id="#+id/listView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#00000000"
android:dividerHeight="4dp"
android:layout_alignParentTop="true"
android:layout_above="#+id/linearLayout" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#mipmap/bisiler_yaz_altplan"
android:id="#+id/linearLayout">
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bisiler_yaz"
android:hint="Bir mesaj yaz..."
android:imeOptions="actionNone"
android:textSize="14dp"
android:textStyle="bold"
android:layout_marginRight="5dp"
android:layout_marginLeft="7dp"
android:layout_marginTop="5dp"
android:capitalize="sentences"
android:allowUndo="true"
android:width="295dp"
android:inputType="textCapSentences" />
<ImageButton
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="bottom"
android:background="#00000000"
android:src="#mipmap/gonder"
android:text="Gonder"
android:layout_marginBottom="10dp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ivYatay"
android:src="#drawable/horizontalrope"
android:layout_marginTop="56dp"
android:layout_marginLeft="118dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ivCapraz"
android:src="#drawable/diagonalrope"
android:layout_marginTop="50dp"
android:layout_marginLeft="92dp"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="invisible"
android:id="#+id/imageView6"
android:background="#mipmap/gri"
android:layout_marginTop="45dp" />
</FrameLayout>
Here is the error :
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:683)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:513)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:889)
at android.content.res.Resources.loadDrawable(Resources.java:3436)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.view.View.<init>(View.java:3708)
at android.widget.ImageView.<init>(ImageView.java:127)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:57)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:53)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:963)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1022)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at droxoft.armin.com.shappy.Mesajlasma.onCreate(Mesajlasma.java:223)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Your OOM error is related to the Images you are loading as I am seeing in your log trace.
See this for loading large Bitmaps more efficiently:
A 400 KB image file can easily take up 5-10 MB of RAM.
For requesting to incraese heap size dynamically, Use android:largeHeap="true"
in the manifest.xml.
or/and just use the proper function to decode...
I would check the size of all your images referred to in your ImageViews. If they are large, maybe encode them as different image types to reduce the image size. The Android system is periodically running out of memory and crashing your application currently. It makes sense that you are getting this only sometimes as it depends on how much memory is currently being used for other applications etc... . If you reduce the size of your images significantly you should be able to resolve this.
Increase the gradle.properties in the root of your project :
org.gradle.jvmargs=-XX:MaxHeapSize\=512m -Xmx512m
the default jvmargs is 256
you can request to use more by using.
android:largeHeap="true"
in the manifest.xml.