App crashes on Nexus 4(4.4.4) due to background image
Asked Answered
M

2

7

I have set background image to root layout. This works fine for nexus 5(5.0.1) and nexus 5x(6.0.1). But on nexus 4(4.4.4) app crash and gives following errors

android.view.InflateException: Binary XML file line #19: Error inflating class at android.view.LayoutInflater.createView(LayoutInflater.java:620) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at com.mobifilia.monitormymortgage.Fragments.HelpScreenFirstFragment.onCreateView(HelpScreenFirstFragment.java:38) 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.run(BackStackRecord.java:742) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570) at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141) at android.support.v4.view.ViewPager.populate(ViewPager.java:1177) at android.support.v4.view.ViewPager.populate(ViewPager.java:1025) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1545) at android.view.View.measure(View.java:16497) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:668) at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:735) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291) at android.view.View.measure(View.java:16497) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1912) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)

This is xml file.

<?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="@drawable/backgraound">


        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="none">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
       // other view
     </LinearLayout>
        </ScrollView>
    </RelativeLayout>

if i remove the background image from xml this works on nexus 4 also. How can I solve this issue?? Thanks in advance

Marijane answered 27/9, 2016 at 5:4 Comment(10)
What @drawable/backgraound contains?Cothran
@piyush this is background image with resolution 320*586 and 343.69 kb size.Marijane
In which drawable folder you have put the images ? Is this drawable-v21 ?Lindell
@ preetika kaur yes it is in drawable-v21Marijane
That is why it is woking in 5.0 and above. Put the images in drawable folder and check now.Lindell
Drawable-v21 means that file is available only for android api level 21 and higher. Android 4.4.4 is api level 19, therefore file is not available.Merriweather
Put image in drawable folder simplyCothran
@preetika kaur , marius kaunietis,piyush thank you very much its working..Marijane
@preetika kaur can you please post this is as answer.Marijane
@Sangram yes sure...Lindell
L
3

You might have put images in drawable-v21 folder which refers to Api level 21 and above. These folders are specific for Lolipop and post Lolipop version. That is why it is not working in Kitkat or more lower versions. Put your images in drawable folder so that all api versions can access this. Happy to help...

Lindell answered 27/9, 2016 at 5:20 Comment(0)
A
1

Just put your image in the drawable folder. drawable -v21 is for android versions>19. Because if this in android 4.4 (api 19), its not able to fetch the image, and it may be throwing the error

Autacoid answered 27/9, 2016 at 5:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.