java - When adding background image : Error inflating class android.widget.ImageButton -


i'm not sure what's causing issue issue, whenever add image resource background imagebutton same error. app started there's barely code. here error:

05-28 12:22:08.158 7186-7186/com.example.myname.appname e/androidruntime: fatal exception: main java.lang.runtimeexception: unable start activity componentinfo{com.example.myname.appname/com.example.litmo.appname.homescreen}: android.view.inflateexception: binary xml file line #22: error inflating class android.widget.imagebutton     @ android.app.activitythread.performlaunchactivity(activitythread.java:2211)     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2261)     @ android.app.activitythread.access$600(activitythread.java:141)     @ android.app.activitythread$h.handlemessage(activitythread.java:1256)     @ android.os.handler.dispatchmessage(handler.java:99)     @ android.os.looper.loop(looper.java:137)     @ android.app.activitythread.main(activitythread.java:5103)     @ java.lang.reflect.method.invokenative(native method)     @ java.lang.reflect.method.invoke(method.java:525)     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737)     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553)     @ dalvik.system.nativestart.main(native method)  caused by: android.view.inflateexception: binary xml file line #22: error inflating class android.widget.imagebutton     @ android.view.layoutinflater.createview(layoutinflater.java:620)     @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56)     @ android.view.layoutinflater.oncreateview(layoutinflater.java:669)     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:694)     @ android.view.layoutinflater.rinflate(layoutinflater.java:755)     @ android.view.layoutinflater.inflate(layoutinflater.java:492)     @ android.view.layoutinflater.inflate(layoutinflater.java:397)     @ android.view.layoutinflater.inflate(layoutinflater.java:353)     @ android.support.v7.app.appcompatdelegateimplv7.setcontentview(appcompatdelegateimplv7.java:249)     @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:106)     @ com.example.myname.appname.homescreen.oncreate(homescreen.java:19)     @ android.app.activity.performcreate(activity.java:5133)     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087)     @ android.app.activitythread.performlaunchactivity(activitythread.java:2175)     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2261)      @ android.app.activitythread.access$600(activitythread.java:141)      @ android.app.activitythread$h.handlemessage(activitythread.java:1256)      @ android.os.handler.dispatchmessage(handler.java:99)      @ android.os.looper.loop(looper.java:137)      @ android.app.activitythread.main(activitythread.java:5103)      @ java.lang.reflect.method.invokenative(native method)      @ java.lang.reflect.method.invoke(method.java:525)      @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737)      @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553)      @ dalvik.system.nativestart.main(native method)   caused by: java.lang.reflect.invocationtargetexception     @ java.lang.reflect.constructor.constructnative(native method)     @ java.lang.reflect.constructor.newinstance(constructor.java:417)     @ android.view.layoutinflater.createview(layoutinflater.java:594)     @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56)      @ android.view.layoutinflater.oncreateview(layoutinflater.java:669)      @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:694)      @ android.view.layoutinflater.rinflate(layoutinflater.java:755)      @ android.view.layoutinflater.inflate(layoutinflater.java:492)      @ android.view.layoutinflater.inflate(layoutinflater.java:397)      @ android.view.layoutinflater.inflate(layoutinflater.java:353)      @ android.support.v7.app.appcompatdelegateimplv7.setcontentview(appcompatdelegateimplv7.java:249)      @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:106)      @ com.example.myname.appname.homescreen.oncreate(homescreen.java:19)      @ android.app.activity.performcreate(activity.java:5133)      @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087)      @ android.app.activitythread.performlaunchactivity(activitythread.java:2175)      @ android.app.activitythread.handlelaunchactivity(activitythread.java:2261)      @ android.app.activitythread.access$600(activitythread.java:141)      @ android.app.activitythread$h.handlemessage(activitythread.java:1256)      @ android.os.handler.dispatchmessage(handler.java:99)      @ android.os.looper.loop(looper.java:137)      @ android.app.activitythread.main(activitythread.java:5103)      @ java.lang.reflect.method.invokenative(native method)      @ java.lang.reflect.method.invoke(method.java:525)      @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737)      @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553)      @ dalvik.system.nativestart.main(native method)   caused by: java.lang.outofmemoryerror     @ android.graphics.bitmapfactory.nativedecodeasset(native method)     @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:503)     @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:356)     @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:800)     @ android.content.res.resources.loaddrawable(resources.java:2110)     @ android.content.res.typedarray.getdrawable(typedarray.java:601)     @ android.view.view.<init>(view.java:3364)     @ android.widget.imageview.<init>(imageview.java:121)     @ android.widget.imagebutton.<init>(imagebutton.java:87)     @ android.widget.imagebutton.<init>(imagebutton.java:83)     @ java.lang.reflect.constructor.constructnative(native method)      @ java.lang.reflect.constructor.newinstance(constructor.java:417)      @ android.view.layoutinflater.createview(layoutinflater.java:594)      @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56)      @ android.view.layoutinflater.oncreateview(layoutinflater.java:669)      @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:694)      @ android.view.layoutinflater.rinflate(layoutinflater.java:755)      @ android.view.layoutinflater.inflate(layoutinflater.java:492)      @ android.view.layoutinflater.inflate(layoutinflater.java:397)      @ android.view.layoutinflater.inflate(layoutinflater.java:353)      @ android.support.v7.app.appcompatdelegateimplv7.setcontentview(appcompatdelegateimplv7.java:249)      @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:106)      @ com.example.myname.appname.homescreen.oncreate(homescreen.java:19)      @ android.app.activity.performcreate(activity.java:5133)      @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087)      @ android.app.activitythread.performlaunchactivity(activitythread.java:2175)      @ android.app.activitythread.handlelaunchactivity(activitythread.java:2261)      @ android.app.activitythread.access$600(activitythread.java:141)      @ android.app.activitythread$h.handlemessage(activitythread.java:1256)      @ android.os.handler.dispatchmessage(handler.java:99)      @ android.os.looper.loop(looper.java:137)      @ android.app.activitythread.main(activitythread.java:5103)      @ java.lang.reflect.method.invokenative(native method)      @ java.lang.reflect.method.invoke(method.java:525)      @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737)      @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553)      @ dalvik.system.nativestart.main(native method)  

here's xml code:

<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="wrap_content" android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin"     android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".homescreen"     android:background="@android:drawable/screen_background_dark_transparent"     android:clickable="true"     android:id="@+id/homescreen_view">      <button         android:layout_width="100.0dp"         android:layout_height="25.0dp"         android:text="help"         android:id="@+id/instructionsbutton"         android:layout_alignparenttop="false"         android:layout_alignparentstart="true"         android:textcolor="#05ffda"         android:background="@android:color/holo_purple"         android:longclickable="true" />      <imagebutton         android:layout_width="50dp"         android:layout_height="50dp"         android:id="@+id/soundenable_button"         android:layout_alignparenttop="true"         android:layout_alignparentend="true"         android:longclickable="true"         android:nestedscrollingenabled="true"         android:background="@drawable/musicoff" />      <button         style="?android:attr/buttonstylesmall"         android:layout_width="100dp"         android:layout_height="25dp"         android:text="highscores"         android:id="@+id/highscores_button"         android:layout_alignparenttop="true"         android:layout_centerhorizontal="true"         android:background="@android:color/holo_purple"         android:textcolor="#05ffda" />      <button         style="?android:attr/buttonstylesmall"         android:layout_width="100dp"         android:layout_height="30dp"         android:text="play game"         android:id="@+id/startgame_button"         android:background="@android:color/holo_purple"         android:textcolor="#05ffda"         android:layout_margintop="175dp"         android:singleline="true"         android:layout_alignparenttop="false"         android:layout_centerhorizontal="true" />  </relativelayout> 

here's java code:

import android.media.image; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.imagebutton; import android.widget.toast;  public class homescreen extends appcompatactivity {       @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_home_screen);       }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.menu_home_screen, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();          //noinspection simplifiableifstatement         if (id == r.id.action_settings) {             return true;         }          return super.onoptionsitemselected(item);     } } 

i have tried code , works me. think problem musicoff drawable , size of it.

try change drawable size or try drawable image , work.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -