Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8941201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:14:47+00:00 2026-06-15T11:14:47+00:00

Since the new update from Android 4.1 to 4.2 on my smartphone, my app

  • 0

Since the new update from Android 4.1 to 4.2 on my smartphone, my app throws an exception, when it initializes a ViewPager and its Activities.

The Exception:

java.lang.IllegalStateException: One or more children of this LayerDrawable does not have constant state; this drawable cannot be mutated.

The StackTrace:

java.lang.RuntimeException: Unable to start activity ComponentInfo{imatuve.info/imatuve.news.NewsTabActivity}: android.view.InflateException: Binary XML file line #3: Error inflating class <unknown>
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
   at android.app.ActivityThread.access$600(ActivityThread.java:141)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:5039)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
   at dalvik.system.NativeStart.main(Native Method)Caused by: android.view.InflateException: Binary XML file line #3: Error inflating class <unknown>
   at android.view.LayoutInflater.createView(LayoutInflater.java:613)
   at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
   at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
   at imatuve.news.NewsTabActivity.createTabView(NewsTabActivity.java:313)
   at imatuve.news.NewsTabActivity.initialiseTabHost(NewsTabActivity.java:261)
   at imatuve.news.NewsTabActivity.onCreate(NewsTabActivity.java:96)
   at android.app.Activity.performCreate(Activity.java:5104)
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
   ... 11 more
    Caused by: java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Constructor.constructNative(Native Method)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
   at android.view.LayoutInflater.createView(LayoutInflater.java:587)
... 23 more
    Caused by: android.content.res.Resources$NotFoundException: File res/drawable/tab_bg_selector.xml from drawable resource ID #0x7f020065
   at android.content.res.Resources.loadDrawable(Resources.java:1953)
   at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
   at android.view.View.<init>(View.java:3328)
   at android.view.View.<init>(View.java:3257)
   at android.view.ViewGroup.<init>(ViewGroup.java:425)
   at android.widget.RelativeLayout.<init>(RelativeLayout.java:210)
   ... 26 more
    Caused by: java.lang.IllegalStateException: One or more children of this LayerDrawable does not have constant state; this drawable cannot be mutated.
   at android.graphics.drawable.LayerDrawable.mutate(LayerDrawable.java:579)
   at android.graphics.drawable.DrawableContainer.selectDrawable(DrawableContainer.java:315)
   at android.graphics.drawable.StateListDrawable.onStateChange(StateListDrawable.java:106)
   at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:189)
   at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:885)
   at android.graphics.drawable.Drawable.createFromXml(Drawable.java:822)
   at android.content.res.Resources.loadDrawable(Resources.java:1950)
   ... 31 more

The Code:

private static View createTabView(final Context context, final String tag) {

            //The exception comes when inflating the view
            View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);

    TextView tv = (TextView)view.findViewById(R.id.tabsText);
    tv.setText(tag);

    return view;
}

tab_bg_selector.xml:

<?xml version="1.0" encoding="utf-8"?>

<!--  Active tab -->
<item android:state_selected="true" android:state_focused="false"
    android:state_pressed="false" android:drawable="@drawable/tab_bg_selected" />
<!--  Inactive tab -->
<item android:state_selected="false" android:state_focused="false"
    android:state_pressed="false" android:drawable="@drawable/tab_bg_unselected" />
<!--  Pressed tab -->
<item android:state_pressed="true" android:drawable="@drawable/tab_bg_pressed" />
<!--  Selected tab  -->
<item android:state_focused="true" android:state_selected="true"
    android:state_pressed="false" android:drawable="@color/transparent" />

tab_pg_pressed.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >   
<item
    android:bottom="8dp"
    android:top="63dp">
    <shape android:shape="rectangle" >
        <solid android:color="#70c0e7fd" />
    </shape>
</item>

<!-- mask out the bottom line of the tab shape -->
<item
    android:left="15dp"
    android:right="15dp"
    android:top="63dp">
    <shape android:shape="rectangle" >
        <corners android:bottomLeftRadius="0dp"
             android:bottomRightRadius="0dp" 
             android:topLeftRadius="3dp"
             android:topRightRadius="3dp" />

        <solid android:color="#70c0e7fd" />
    </shape>
</item>  

tab_bg_selected.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:bottom="8dp"
    android:top="63dp">
    <shape android:shape="rectangle" >
        <solid android:color="#ffc0e7fd" />
    </shape>
</item>

<!-- mask out the bottom line of the tab shape -->
<item
    android:left="15dp"
    android:right="15dp"
    android:top="63dp">
    <shape android:shape="rectangle" >
        <corners android:bottomLeftRadius="0dp"
             android:bottomRightRadius="0dp" 
             android:topLeftRadius="3dp"
             android:topRightRadius="3dp" />

        <solid android:color="#ffc0e7fd" />
    </shape>
</item> 

tab_bg_unselected.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
</layer-list>

The “tabs_bg” layout exists in my layout folder, just like the res/drawable/tab_bg_selector.xml.

On a Android 4.1 OS or lower this exception doesn’t occur.
What can this be and how do I get rid of it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:14:49+00:00Added an answer on June 15, 2026 at 11:14 am

    I found the Problem. It lies in the tab_bg_unselected.xml.

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    </layer-list>
    

    Obviously in Android 4.2 the layer-list must have at least one child. So I added an item to the list and the app doesn’t throw the exception again!

    But it’s not enough to add an ’empty’ item! It also has to be a content, like a shape or so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

since the new Auth Dialog from Facebook (for my App & homepage), I cannot
Since http is stateless, every request to an app creates a new object. How
Since Android ICS we have problems to verify our certificates we are getting from
So I am quite new to Android, and have limited previous Java experience, so
I am working on a small MFC application..since am new to MFC I am
Since i am new to CSS, i am not sure if the following page
I got a new mac since the old one crashed and was trying to
This might seem a bit weird, but since I am new in RoR and
I am playing with F# in VS2010 beta2, and since I am new to
since Windows Vista there is an new Win32-API call CreateSymbolicLink to create a symbolic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.