Question

hi im having a problem in 2 activities in my app that is throwing this error, Error inflating class it seems to be similar to this question ; Unknown inflate error with android

one of the activities is doing nothing but loading an animation and used to work fine i don't believe i have changed anything and it has no XML errors i'm getting this in the log

Caused by: android.view.InflateException: Binary XML file line #9: Error inflating     

class can anyone see what i have done wrong? i'm still quite new at this, here is my code

xml

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_layered"
android:layout_width="fill_parent"
android:layout_height="fill_parent">



<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:contentDescription="@string/bus_image"
    android:id="@+id/busImageView"
    android:background="@drawable/movingbus"
    android:layout_alignParentBottom="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true" />
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/bus_text"
    android:id="@+id/text_View"
    android:textSize="23sp"
    android:gravity="center"
    android:textStyle="bold|italic"
    android:background="@android:color/transparent" />

<Button
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:id="@+id/nextbutton"
    android:background="@drawable/fnshdbtn"
    android:layout_gravity="center"
    android:onClick="nextImage2"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true" />

<Button
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/button2"
    android:background="@android:color/transparent"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/text_View"
    android:layout_alignParentLeft="true"
    android:layout_above="@+id/nextbutton" />



</RelativeLayout>

java

public class BusActivity extends ActionBarActivity {
AnimationDrawable schoolBus;
Button b;
Button btn;
TextView t;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_bus);
    b = (Button) findViewById(R.id.nextbutton);
    btn = (Button)findViewById(R.id.button2);
    t = (TextView)findViewById(R.id.text_View);
    Typeface newfont = Typeface.createFromAsset(getAssets(),"fonts/MarkerFelt.ttf");
    t.setTypeface(newfont);
    ImageView movingbus = (ImageView) findViewById(R.id.busImageView);
    movingbus.setBackgroundResource(R.drawable.movingbus);
    schoolBus = (AnimationDrawable) movingbus.getBackground();

    schoolBus.start();




    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            MediaPlayer mp = MediaPlayer.create(BusActivity.this, R.raw.bushorn);
            mp.start();
        }
    });



}

public void nextImage2(View view){
    Intent intent = new Intent(this, socialActivity.class);
    startActivity(intent);
    finish();
}
}

and here is the log cat

--- allocation failed for scaled bitmap
04-26 01:34:36.021    6000-6000/com.martinsapp.socialstories D/AndroidRuntime﹕ Shutting 

down VM
04-26 01:34:36.021    6000-6000/com.martinsapp.socialstories W/dalvikvm﹕ threadid=1:   
thread exiting with uncaught exception (group=0x41d76d88)
04-26 01:34:36.031    6000-6000/com.martinsapp.socialstories E/AndroidRuntime﹕ FATAL    
EXCEPTION: main
Process: com.martinsapp.socialstories, PID: 6000
java.lang.RuntimeException: Unable to start activity    
ComponentInfo{com.martinsapp.socialstories/com.martinsapp.socialstories.BusActivity}:  
android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2248)
           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2298)
           at android.app.ActivityThread.access$800(ActivityThread.java:144)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
           at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:212)
        at android.app.ActivityThread.main(ActivityThread.java:5151)
        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:877)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
        at dalvik.system.NativeStart.main(Native Method)
   Caused by: android.view.InflateException: Binary XML file line #9: Error inflating  

class <unknown>
        at android.view.LayoutInflater.createView(LayoutInflater.java:620)

at
com.android.internal.policy.impl.PhoneLayoutIn
flater.onCreateView(PhoneLayoutInflater.java:56)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
        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 android.view.LayoutInflater.inflate(LayoutInflater.java:353)
        at   
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:297)
        at android.app.Activity.setContentView(Activity.java:1929)
        at   
android.support.v7.app.ActionBarActivity.
superSetContentView(ActionBarActivity.java:208)
        at  android.support.v7.app.ActionBarActivityDelegateICS.
setContentView(ActionBarActivityDelegateICS.java:111)
        at  
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
        at com.martinsapp.socialstories.BusActivity.onCreate(BusActivity.java:31)
        at android.app.Activity.performCreate(Activity.java:5231)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
        at android.app.ActivityThread.performLaunchActivity

(ActivityThread.java:2212)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2298)   
 at android.app.ActivityThread.access$800(ActivityThread.java:144)

    

Was it helpful?

Solution

Looking at your log allocation failed for scaled bitmap.

Issue could be with the images your using. Try to change the image.

This crash might be happening due to out of memory in random scenario.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top