i have a dashboard layout that has several images. When i run the app i get force close error and the error point to this line in dashboard avtivty where inflate the layout(i.e setContentView(R.layout.dashboard). I dont understand why. I used the same Dashboard layout with other images and all was fine. Now it has six images but much bigger in size. I don't know if this is the problem and how to solve this? thanks. Here is my dashboardlayout.
<com.utils.DashboardLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background" >
<Button
android:id="@+id/home_btn_general_knowledge"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/general_knowledge_icon_bg_selector"
android:onClick="onGeneralKnowledgeClick"
android:text="General Knowledge" />
<Button
android:id="@+id/home_btn_brainteasers"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/brain_teasers_icon_bg_selector"
android:onClick="onBrainTeasersClick"
android:text="Brain Teasers" />
<Button
android:id="@+id/home_btn_movies"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/movies_icon_bg_selector"
android:onClick="onMoviesClick"
android:text="Movies" />
<Button
android:id="@+id/home_btn_sports"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/sports_icon_bg_selector"
android:onClick="onSportsClick"
android:text="Sports" />
<Button
android:id="@+id/home_btn_music"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/music_icon_bg_selector"
android:onClick="onMusicClick"
android:text="Music" />
<Button
android:id="@+id/home_btn_celebrities"
style="@style/DPDashBoardButton"
android:drawableTop="@drawable/celebrity_icon_bg_selector"
android:onClick="onCelebritiesClick"
android:text="Celebrities" />
Here is the error logcat:
01-08 02:29:29.216: E/AndroidRuntime(4221): FATAL EXCEPTION: main
01-08 02:29:29.216: E/AndroidRuntime(4221): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hussein.android./com.hussein.android.DashBoardActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class android.widget.Button
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.os.Looper.loop(Looper.java:123)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-08 02:29:29.216: E/AndroidRuntime(4221): at java.lang.reflect.Method.invokeNative(Native Method)
01-08 02:29:29.216: E/AndroidRuntime(4221): at java.lang.reflect.Method.invoke(Method.java:507)
01-08 02:29:29.216: E/AndroidRuntime(4221): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-08 02:29:29.216: E/AndroidRuntime(4221): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-08 02:29:29.216: E/AndroidRuntime(4221): at dalvik.system.NativeStart.main(Native Method)
01-08 02:29:29.216: E/AndroidRuntime(4221): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.widget.Button
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
01-08 02:29:29.216: E/AndroidRuntime(4221): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-08 02:29:29.216: E/AndroidRuntime(4221): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.Activity.setContentView(Activity.java:1657)
01-08 02:29:29.216: E/AndroidRuntime(4221): at com.hussein.android.quizgame.DashBoardActivity.onCreate(DashBoardActivity.java:18)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-08 02:29:29.216: E/AndroidRuntime(4221): ... 11 more
01-08 02:29:29.216: E/AndroidRuntime(4221): Caused by: java.lang.reflect.InvocationTargetException
01-08 02:29:29.216: E/AndroidRuntime(4221): at java.lang.reflect.Constructor.constructNative(Native Method)
01-08 02:29:29.216: E/AndroidRuntime(4221): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
01-08 02:29:29.216: E/AndroidRuntime(4221): ... 22 more
01-08 02:29:29.216: E/AndroidRuntime(4221): Caused by: java.lang.StackOverflowError
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable$StateListState.indexOfStateSet(StateListDrawable.java:274)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable$StateListState.access$000(StateListDrawable.java:253)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.onStateChange(StateListDrawable.java:95)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.<init>(StateListDrawable.java:306)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.<init>(StateListDrawable.java:70)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:749)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.loadDrawable(Resources.java:1694)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.getDrawable(Resources.java:581)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.loadDrawable(Resources.java:1694)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.getDrawable(Resources.java:581)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.loadDrawable(Resources.java:1694)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.content.res.Resources.getDrawable(Resources.java:581)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
01-08 02:29:29.216: E/AndroidRuntime(4221): at android.graphics.drawable.Drawable.createFromXml(Dr
01-08 02:29:29.327: D/dalvikvm(4221): GC_CONCURRENT freed 284K, 52% free 2749K/5639K, external 6582K/8020K, paused 7ms+7ms
Here is a one of my the drawables sports_icon_bg_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/sports" android:state_focused="true" android:state_pressed="false"/>
<item android:drawable="@drawable/sports" android:state_focused="true" android:state_pressed="true"/>
<item android:drawable="@drawable/sports_blue" android:state_focused="false" android:state_pressed="true"/>
<item android:drawable="@drawable/sports"/>
</selector>
You have a circular definition of your drawables. One (or more) of your selectors references something that references the selector again. (Or perhaps it references itself.)
(In my opinion, the resource compiler should catch this, but it apparently doesn't.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With