Android layout inflate exception in fragments - android

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.

Related

How to fix:android.app.RemoteServiceException: Bad notification posted from package XXX: Couldn't inflate contentViewsandroid.view.InflateException

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

Binary XML file line #28: Error inflating class android.widget.TextView

This is my layout:-
<?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:background="#fdfdfe"
tools:context=".activity.LoginActivity">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_lay_login"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="42sp">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:layout_marginTop="42sp"
android:src="#drawable/foodx_restaurant_logo" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="42sp"
android:text="#string/enter_the_details_to_login"
android:textColor="#color/colorPrimaryText"
android:textSize="13sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="42sp"
android:text="#string/email"
android:textColor="#color/colorPrimaryText"
android:textSize="10sp" />
<EditText
android:id="#+id/et_email"
android:layout_width="match_parent"
android:layout_height="32sp"
android:layout_marginTop="4sp"
android:background="#drawable/edit_text_rounded_corner_bg"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:padding="4sp"
android:textColor="#color/colorSecondaryText"
android:textSize="13sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="42sp"
android:text="#string/password"
android:textColor="#color/colorPrimaryText"
android:textSize="10sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4sp"
android:background="#drawable/edit_text_rounded_corner_bg"
android:orientation="horizontal">
<EditText
android:id="#+id/et_password"
android:layout_width="match_parent"
android:layout_height="32sp"
android:layout_weight="1"
android:background="#null"
android:hint="#string/password"
android:imeOptions="actionDone"
android:inputType="textWebPassword"
android:padding="4sp"
android:textColor="#color/colorSecondaryText"
android:textSize="13sp" />
<ImageView
android:id="#+id/et_password_eye_img"
android:layout_width="30sp"
android:layout_height="match_parent"
android:layout_marginRight="4sp"
android:contentDescription="#string/app_name"
android:padding="4sp"
android:src="#drawable/ic_eye_open"
android:tint="#color/grey" />
</LinearLayout>
<TextView
android:id="#+id/txt_forgot_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="42sp"
android:text="#string/forgot_password"
android:textColor="#color/colorTheme"
android:textSize="13sp" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:id="#+id/bottom_lay_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginStart="42sp"
android:layout_marginEnd="42sp"
android:orientation="vertical">
<Button
android:id="#+id/login_btn"
android:layout_width="match_parent"
android:layout_height="42sp"
android:layout_marginTop="42sp"
android:background="#drawable/rounded_button"
android:text="#string/login"
android:textColor="#color/colorWhite" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/donot_have_an_account"
android:textColor="#color/colorPrimaryText"
android:textSize="10sp" />
<TextView
android:id="#+id/txt_register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="42sp"
android:paddingTop="42sp"
android:paddingBottom="42sp"
android:text="#string/register"
android:textAllCaps="false"
android:textColor="#color/colorTheme"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
These are my logs:-
Caused by: android.view.InflateException: Binary XML file line #28 in com.dw.foodxrestaurant:layout/activity_login: Binary XML file line #28 in com.dw.foodxrestaurant:layout/activity_login: Error inflating class TextView
Caused by: android.view.InflateException: Binary XML file line #28 in com.dw.foodxrestaurant:layout/activity_login: Error inflating class TextView
Caused by: java.lang.IndexOutOfBoundsException: index=0 out of bounds (limit=0, nb=4)
at java.nio.Buffer.checkIndex(Buffer.java:564)
at java.nio.DirectByteBuffer.getInt(DirectByteBuffer.java:570)
at android.graphics.fonts.FontFileUtil.analyzeStyle(FontFileUtil.java:94)
at android.graphics.fonts.Font$Builder.build(Font.java:364)
at android.graphics.Typeface$Builder.build(Typeface.java:596)
at android.content.res.ResourcesImpl.loadFont(ResourcesImpl.java:1032)
at android.content.res.Resources.getFont(Resources.java:408)
at android.content.res.TypedArray.getFont(TypedArray.java:1035)
at android.widget.TextView.readTextAppearance(TextView.java:4029)
at android.widget.TextView.<init>(TextView.java:1079)
at android.widget.TextView.<init>(TextView.java:978)
at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:99)
at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:95)
at androidx.appcompat.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:182)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1407)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1457)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1063)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:999)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:963)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1125)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1128)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1128)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.dw.foodxrestaurant.activity.LoginActivity.onCreate(LoginActivity.java:76)
I am unable to get the problems but I have checked all my libraries are up to date, Clean project and also invalidate and restart my studio.
Note:- Devices till android 9 are working fine with the same code but android 10 is giving me error
There is an issue with andrpid Q, something with text font loading sometimes, In your stacktrace too I can see the issue, If you are using any custom font file check it, If you are not using any font, then import a font file u are supporting in your project , so that If it s does not get it from os, It can get it from asset.
Check below link
Crash when using bundled ttf font on Android 10 / Android Q
I think your problem with ImageView display image its larger than the screen try to replace by some color code and check
android:src="#drawable/foodx_restaurant_logo"
replace this image
As per your xml the error points to Textview and it is related to some of the details in textview.
I think the problem is that the colorPrimaryText is not set properly. Please make sure that this property is set properly .
I have tried running your code in android 10 and it works fine.
Please do check and try this solution.
Hope this will resolve your issue.

How to inflate a view in android in API level 25 and below?

I am getting error in inflating a view in recycler view. It works on Oreo and Pie but not working in Nougat and devices below it.
This is the code I have used to inflating the view.
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.listing_row_item, parent, false);
My xml file is
<?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"
android:background="#drawable/outlined_blue_rectangle"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
android:layout_marginBottom="#dimen/row_padding"
android:paddingBottom="#dimen/contentPadding"
android:paddingStart="#dimen/contentPadding"
android:paddingEnd="#dimen/contentPadding"
android:paddingTop="#dimen/contentPadding">
<LinearLayout
android:id="#+id/ll_name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Name"
android:layout_height="wrap_content"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
<TextView
android:id="#+id/name"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_status"
android:layout_below="#+id/ll_name"
android:layout_marginTop="#dimen/verticalSpacing"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Loan Application Status"
android:layout_height="wrap_content"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
<TextView
android:id="#+id/status"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_eligibility"
android:layout_below="#+id/ll_status"
android:layout_marginTop="#dimen/verticalSpacing"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Eligibility Status"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
<TextView
android:id="#+id/preliminary_eligibility"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
</LinearLayout>
**<Button**
android:id="#+id/check_eligibility"
android:layout_below="#+id/ll_eligibility"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/verticalSpacing"
android:paddingStart="#dimen/row_padding"
android:paddingEnd="#dimen/row_padding"
android:text="Check\nEligibility"
android:layout_alignParentEnd="true"
android:textAllCaps="false"
android:background="#drawable/button_selection_selected"
android:textColor="#color/whiteColor"
android:textSize="#dimen/textSizeSmall" />
<Button
android:id="#+id/all_info"
android:layout_below="#+id/ll_eligibility"
android:layout_marginTop="#dimen/verticalSpacing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="#dimen/row_padding"
android:paddingEnd="#dimen/row_padding"
android:text="All\nInfo"
android:textAllCaps="false"
android:background="#drawable/button_selection_selected"
android:textColor="#color/whiteColor"
android:textSize="#dimen/textSizeSmall"/>
</RelativeLayout>
The error message I am getting
android.view.InflateException: Binary XML file line #88: Binary XML file line #88: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #88: Error inflating class Button
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=31; index=464
at android.content.res.StringBlock.get(StringBlock.java:65)
at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:1212)
at android.content.res.TypedArray.getString(TypedArray.java:202)
at android.widget.TextView.<init>(TextView.java:1100)
at android.widget.Button.<init>(Button.java:109)
at android.widget.Button.<init>(Button.java:105)
at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:71)
at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:67)
If you are using layout that only supports API level 25+, you should put it inside a res/layout-v25 folder (create the folder if it doesn't exist), and you must create a substitute layout for API level 24 below inside res/layout folder.
Android will automatically use layout-v25 on API level 25+.

Google Play Console reports InflateException without further details, only on some LG models: how go deeper?

My app is very simple and shows an Android Map on main Activity. It works perfectly on several Phones and Tablets (not from LG) that I own.
Google Play Console reports the following Exception mostly on some LG devices and only on Android 6.0:
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5551)
at java.lang.reflect.Method.invoke(Native Method:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Caused by: android.view.InflateException:
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:401)
at android.app.Activity.setContentView(Activity.java:2171)
at com.mdc.nasoni.mdcNasoni.onCreate(mdcNasoni.java:125)
at android.app.Activity.performCreate(Activity.java:6272)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
Layout is as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/log"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FF0000" />
<RelativeLayout
android:id="#+id/mapcontainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="#+id/ButtonSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="#string/button01"
android:visibility="gone" />
<Button
android:id="#+id/Button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:visibility="gone" />
<Button
android:id="#+id/ButtonCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/button03"
android:visibility="gone" />
<Button
android:id="#+id/ButtonLayers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/ic_layers"
android:onClick="layersButtonClicked" />
<TextView
android:id="#+id/splashTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/title_background"
android:drawableBottom="#drawable/icon"
android:padding="5dp"
android:text="#string/app_name" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/cross" />
<View
android:id="#+id/anchor"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true" />
<ImageView
android:id="#+id/nasoneGreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/anchor"
android:layout_centerHorizontal="true"
android:src="#drawable/nasone_green"
android:visibility="gone"
/>
</RelativeLayout>
</LinearLayout>
And this is the onCreate() in the main Activity:
/**
* Called when the activity is first created.
*/
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
I cannot see in the crash report any detail on what is causing it: any suggestion on how I could go deeper?
Thank you,
Max
UPDATE
It seems solved replacing
compile 'com.google.android.gms:play-services:+'
with
compile 'com.google.android.gms:play-services:9.6.1'
It seems solved replacing
compile 'com.google.android.gms:play-services:+'
with
compile 'com.google.android.gms:play-services:9.6.1'

Android OutOfMemoryError in SetContentView line

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.

Categories

Resources