-2

while launching my app I am getting following exception:

I am adding my code at below please check once

05-16 10:44:16.653: E/AndroidRuntime(979): FATAL EXCEPTION: main
05-16 10:44:16.653: E/AndroidRuntime(979): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thenewboston.travis/com.thenewboston.travis.Splash}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.os.Looper.loop(Looper.java:137)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.app.ActivityThread.main(ActivityThread.java:5039)
05-16 10:44:16.653: E/AndroidRuntime(979):  at java.lang.reflect.Method.invokeNative(Native Method)
05-16 10:44:16.653: E/AndroidRuntime(979):  at java.lang.reflect.Method.invoke(Method.java:511)
05-16 10:44:16.653: E/AndroidRuntime(979):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-16 10:44:16.653: E/AndroidRuntime(979):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-16 10:44:16.653: E/AndroidRuntime(979):  at dalvik.system.NativeStart.main(Native Method)
05-16 10:44:16.653: E/AndroidRuntime(979): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.view.LayoutInflater.createView(LayoutInflater.java:613)
05-16 10:44:16.653: E/AndroidRuntime(979):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-16 10:44:16.653: E/AndroidRuntime(979):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.app.Activity.setContentView(Activity.java:1881)
05-16 10:44:16.653: E/AndroidRuntime(979):  at com.thenewboston.travis.Splash.onCreate(Splash.java:16)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.app.Activity.performCreate(Activity.java:5104)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-16 10:44:16.653: E/AndroidRuntime(979):  ... 11 more
05-16 10:44:16.653: E/AndroidRuntime(979): Caused by: java.lang.reflect.InvocationTargetException
05-16 10:44:16.653: E/AndroidRuntime(979):  at java.lang.reflect.Constructor.constructNative(Native Method)
05-16 10:44:16.653: E/AndroidRuntime(979):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.view.LayoutInflater.createView(LayoutInflater.java:587)
05-16 10:44:16.653: E/AndroidRuntime(979):  ... 23 more
05-16 10:44:16.653: E/AndroidRuntime(979): Caused by: java.lang.OutOfMemoryError
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.content.res.Resources.loadDrawable(Resources.java:1965)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.view.View.<init>(View.java:3328)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.view.ViewGroup.<init>(ViewGroup.java:431)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.widget.LinearLayout.<init>(LinearLayout.java:176)
05-16 10:44:16.653: E/AndroidRuntime(979):  at android.widget.LinearLayout.<init>(LinearLayout.java:172)
05-16 10:44:16.653: E/AndroidRuntime(979):  ... 26 more

I am adding my code at below please check once I don't know why inflate exception is occurring I am new to Android please help me

Splash.java

package com.thenewboston.travis;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.preference.PreferenceManager;

public class Splash extends Activity{
MediaPlayer mySong;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        mySong = MediaPlayer.create(Splash.this, R.raw.honey);

        SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        boolean musicChk = getPrefs.getBoolean("checkbox", true);
        if(musicChk == true)

            mySong.start();

        Thread timer = new Thread(){
            public void run(){
                try{
                    sleep(1000);
                }
                catch(InterruptedException e){
                    e.printStackTrace();                    
                }finally{
                    System.out.println("Coming HERE...............");
                    Intent openStartingPoint = new Intent ("com.thenewboston.travis.MENU");
                    startActivity(openStartingPoint); 

                }
            }
        };
        timer.start();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        mySong.release();
        finish();
    }


}

Splash.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="@drawable/honey">


</LinearLayout>
  • 1
    it means there is a problem in your code – chopchop May 16 '13 at 10:50
  • Somthing wrong with xml . Post Splash and the xml it inflates – Blackbelt May 16 '13 at 10:50
  • 1
    That java.lang.OutOfMemoryError looks interesting. Perhaps the Drawable for the splash image you're trying to inflate is way too big? – Austin B May 16 '13 at 10:53
  • This always happens with splash screens. It's God's way of telling you that they are evil. http://cyrilmottier.com/2012/05/03/splash-screens-are-evil-dont-use-them/ – Simon May 16 '13 at 11:45

2 Answers2

0

The name says it all OutOfMemoryError means you are trying to allocate more than you should.

com.thenewboston.travis.Splash means you are doing that in your splash activty.

Conclusion is you are trying to set a very big image as a background. I'd suggest minimizing the size by using 1 or 2 9-patches.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
0
  1. Caused by: android.view.InflateException: Binary XML file line #2

its nothing but something wrong in your xml file.

  1. Caused by: java.lang.reflect.InvocationTargetException

its means some variable have null values which you try to get.

  1. Caused by: java.lang.OutOfMemoryError

its occurs when you use to get too big image or big size image. mostly it occurs in galaxy s3 mobile whenever you take picture using camera intent.

Sagar Maiyad
  • 12,655
  • 9
  • 63
  • 99
  • Thank you for your support. I am getting this exception due to using wrong size emulator.After i upgrade my emulator configuration the exception is not occurring – user2235614 May 17 '13 at 04:32