Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7743921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:39:29+00:00 2026-06-01T09:39:29+00:00

I am also new to Java and Android Development, been making a simple game

  • 0

I am also new to Java and Android Development, been making a simple game on my Wildfire S for a while and things have been going well except whenever I get a Null Pointer Exception I cannot seem to find what exactly is causing it.

All forums I have searched on, detail what a Null Pointer Exception is or how to pre-emptively overcome them but that is not what I need.

The problem I face here is that the part of code that Eclipse seems to be drawing my attention to seems completely fine and I haven’t been editing it at all. So I have possibly changed something by mistake somewhere. Not knowing which area has been edited I cannot seem to find out why the error is being thrown.

The log seems to tell me that the error is occuring at the onCreate method in GoalieMenu.java which hasn’t been edited in a very long time. It is simply an Activity which uses mainmenu.xml as its layout, which contains three buttons (start, howToPlay and Exit) each button has XMLs of their own they all seem fine…

I fear this is going to be a really dumb and obvious thing but I’m not greatly familiar with what I am looking at so it is taking me ages and I cannot find it!! grr

here is the log:

04-04 16:27:57.277: ERROR/AndroidRuntime(2831): FATAL EXCEPTION: main
04-04 16:27:57.277: ERROR/AndroidRuntime(2831): java.lang.RuntimeException: Unable 
to  start activity     
ComponentInfo{com.luk.games.Goalie/com.luk.games.Goalie.GoalieMenu}:
java.lang.NullPointerException
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1830)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
android.app.ActivityThread.access$1500(ActivityThread.java:132)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
android.os.Looper.loop(Looper.java:150)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
android.app.ActivityThread.main(ActivityThread.java:4277)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
java.lang.reflect.Method.invokeNative(Native Method)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
java.lang.reflect.Method.invoke(Method.java:507)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
dalvik.system.NativeStart.main(Native Method)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831): Caused by: 
java.lang.NullPointerException

04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
com.luk.games.Goalie.GoalieMenu.onCreate(GoalieMenu.java:34)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794)
04-04 16:27:57.277: ERROR/AndroidRuntime(2831):     ... 11 more

Here is the GoalieMenu.java:

package com.luk.games.Goalie;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class GoalieMenu extends Activity {

private Button startGameButton;
private Button howToPlayButton;
private Button exitButton;

@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.mainmenu);

      this.startGameButton = (Button)this.findViewById(R.id.startGameButton);
      this.startGameButton.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
          startActivity(new Intent("com.luk.games.Goalie.GameActivity"));       
          }
      });

       this.howToPlayButton = (Button)this.findViewById(R.id.howToPlayButton);
       this.howToPlayButton.setOnClickListener(new OnClickListener() {
           public void onClick(View v) {
              startActivity(new Intent("com.luk.games.Goalie.HowToPlayActivity"));              
            }
        });

       this.exitButton = (Button)this.findViewById(R.id.exitButton);
       this.exitButton.setOnClickListener(new OnClickListener() {
           public void onClick(View v) {
               finish();
           }
       });
}
}

mainmenu.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:background="@drawable/mainmenuscreen"
    android:layout_height="match_parent" android:orientation="vertical">
<Button 
    android:id="@+id/startGameButton"
    android:background="@layout/startgamebutton"
    android:layout_height="50dp" 
    android:layout_width="180dp"
    android:layout_gravity="center"
    android:layout_marginTop="100dip"/>
<Button 
    android:id="@+id/howToPlayButton"
    android:background="@layout/howtoplaybutton"
    android:layout_height="50dp" 
    android:layout_width="180dp"
    android:layout_gravity="center"/>
<Button
    android:id="@+id/exitButton"
    android:background="@layout/exitbutton"
    android:layout_height="50dp"
    android:layout_width="180dp"
    android:layout_gravity="center"/>
</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:39:31+00:00Added an answer on June 1, 2026 at 9:39 am

    GoalieMenu.java:34, I think it is this this howToPlayButton.setOnClickListener

    howToPlayButton might be null.

    Debug and use try and catch where you suspect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Java and Android development so I decided to make a simple
I'm pretty new to Android development, but I have some experience with Java and
I'm new to Android Java programming. I've created a simple chat app. Things are
I'm quite new to Android and I have been reading the Professional Android 2
I'm new to Android development and it's been a long time since I've done
I have been digging into the question for a while in StackOverflow Android get
I'm very new to Android development (just started today), and also very new to
I'm new to both Java and Android development so this might be a stupid
I have built a new development machine and installed Android SDK. I tried to
I am new to java, eclipse, and android development, so I may be missing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.