1. Download our Official Android App: Forums for Android!

Apps NullPointerException in onCreate?

Discussion in 'Android Development' started by eatfishy, Feb 13, 2011.

  1. eatfishy

    eatfishy Guest
    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    I am getting this error message on new android phone models, but it works fine on my Droid Phone using 2.2 OS. Does anyone know how to troubleshoot this error message?

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.simpoware.omgannoyingsounds/com.simpoware.omgannoyingsounds.TabBar}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.simpoware.omgannoyingsounds/com.simpoware.omgannoyingsounds.Main}: java.lang.NullPointerException
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:651)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.simpoware.omgannoyingsounds/com.simpoware.omgannoyingsounds.Main}: java.lang.NullPointerException
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
    at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
    at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
    at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:673)
    at android.widget.TabHost.setCurrentTab(TabHost.java:345)
    at android.widget.TabHost.addTab(TabHost.java:224)
    at com.simpoware.omgannoyingsounds.TabBar.onCreate(TabBar.java:39)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    ... 11 more
    Caused by: java.lang.NullPointerException
    at com.simpoware.omgannoyingsounds.Main.onCreate(Main.java:57)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    ... 20 more




    Below is my code:


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    //greystripe
    myBanner = (BannerView) findViewById(R.id.gsBanner);
    myBanner.refresh();

    //set audio player
    player01 = MediaPlayer.create(this, R.raw.modem);
    player02 = MediaPlayer.create(this, R.raw.high_pitch_dog_whistle);
    player03 = MediaPlayer.create(this, R.raw.alarm_clock);
    player04 = MediaPlayer.create(this, R.raw.faulty_mechanics_sound);
    player05 = MediaPlayer.create(this, R.raw.mosquito);
    player06 = MediaPlayer.create(this, R.raw.buzz);
    player07 = MediaPlayer.create(this, R.raw.strange_static);
    player08 = MediaPlayer.create(this, R.raw.piece_of_crap);
    player09 = MediaPlayer.create(this, R.raw.house_fire_alarm);
    player10 = MediaPlayer.create(this, R.raw.hailstorm);
    player11 = MediaPlayer.create(this, R.raw.electric_toothbrush);
    player12 = MediaPlayer.create(this, R.raw.ecg);

    player01.setLooping(true); // Set looping
    player02.setLooping(true); // Set looping
    player03.setLooping(true); // Set looping
    player04.setLooping(true); // Set looping
    player05.setLooping(true); // Set looping
    player06.setLooping(true); // Set looping
    player07.setLooping(true); // Set looping
    player08.setLooping(true); // Set looping
    player09.setLooping(true); // Set looping
    player10.setLooping(true); // Set looping
    player11.setLooping(true); // Set looping
    player12.setLooping(true); // Set looping


    // Get the ImageButton from XML
    imgButton01 = (ImageButton) this.findViewById(R.id.ImageButton01);
    imgButton02 = (ImageButton) this.findViewById(R.id.ImageButton02);
    imgButton03 = (ImageButton) this.findViewById(R.id.ImageButton03);
    imgButton04 = (ImageButton) this.findViewById(R.id.ImageButton04);
    imgButton05 = (ImageButton) this.findViewById(R.id.ImageButton05);
    imgButton06 = (ImageButton) this.findViewById(R.id.ImageButton06);
    imgButton07 = (ImageButton) this.findViewById(R.id.ImageButton07);
    imgButton08 = (ImageButton) this.findViewById(R.id.ImageButton08);
    imgButton09 = (ImageButton) this.findViewById(R.id.ImageButton09);
    imgButton10 = (ImageButton) this.findViewById(R.id.ImageButton10);
    imgButton11 = (ImageButton) this.findViewById(R.id.ImageButton11);
    imgButton12 = (ImageButton) this.findViewById(R.id.ImageButton12);

    //Set click listener
    imgButton01.setOnClickListener(this);
    imgButton02.setOnClickListener(this);
    imgButton03.setOnClickListener(this);
    imgButton04.setOnClickListener(this);
    imgButton05.setOnClickListener(this);
    imgButton06.setOnClickListener(this);
    imgButton07.setOnClickListener(this);
    imgButton08.setOnClickListener(this);
    imgButton09.setOnClickListener(this);
    imgButton10.setOnClickListener(this);
    imgButton11.setOnClickListener(this);
    imgButton12.setOnClickListener(this);

    }


    Again, it works fine on my droid phone and ran smoothly on the emulator. Many users tried to download my app and it doesn't work for their android phones, which are droid2, droidx, milestone, any new model..
     

    Advertisement

  2. Tapirboy

    Tapirboy Newbie
    Rank:
    None
    Points:
    15
    Posts:
    42
    Joined:
    Feb 10, 2011

    Hmm. which line is line 57?
     

Share This Page

Loading...