0

I am getting a NullPointerException in my menu_layout.xml file. I am extending a LayoutGameActivity class in order to use EditText. Before posting here I already googled a lot but had no luck fixing it. I also updated ADT like some suggested but nothing.

menu_layout.xml error log:

java.lang.NullPointerException
Couldn't resolve resource @id/gameSurfaceView
Exception details are logged in Window > Show View > Error Log

java.lang.NullPointerException
at org.andengine.opengl.view.RenderSurfaceView.onMeasure(RenderSurfaceView.java:66)
at android.view.View.measure(View.java:8173)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365)
at android.view.View.measure(View.java:8173)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8173)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1015)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:384)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:307)
at android.view.View.measure(View.java:8173)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1015)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:384)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:307)
at android.view.View.measure(View.java:8173)

menu_layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MenuActivity" >

<org.andengine.opengl.view.RenderSurfaceView
android:id="@+id/gameSurfaceView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:contentDescription="@null"
    android:src="@drawable/vision" />

<EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:hint="@string/uHint"
    android:inputType="textEmailAddress" >

</EditText>

<EditText
    android:id="@+id/editText2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:hint="@string/pHint"
    android:inputType="textPassword" />

</RelativeLayout

MenuActivity.java

public class MenuActivity extends LayoutGameActivity{

Scene scene;
protected final static int CAMERA_WIDTH = 800;
protected final static int CAMERA_HEIGHT = 480;

BoundCamera mCamera;


@Override
protected int getLayoutID() {
return R.layout.menu_layout;
}
@Override
protected int getRenderSurfaceViewID() {
return R.id.gameSurfaceView;
}



@Override
public EngineOptions onCreateEngineOptions() {

    mCamera = new BoundCamera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);


    EngineOptions options = new EngineOptions(true,
            ScreenOrientation.LANDSCAPE_SENSOR, new  RatioResolutionPolicy(CAMERA_WIDTH,CAMERA_HEIGHT), mCamera);
    return options;

}

@Override
public Engine onCreateEngine(EngineOptions pEngineOptions) {
    // 60 FPS
    return new LimitedFPSEngine(pEngineOptions, 60);
}


@Override
public void onCreateResources(
        OnCreateResourcesCallback pOnCreateResourcesCallback)
        throws IOException {

    pOnCreateResourcesCallback.onCreateResourcesFinished();
}

@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback)
        throws IOException {
    // TODO Auto-generated method stub
    Scene sc = new Scene();

    pOnCreateSceneCallback.onCreateSceneFinished(sc);
}

@Override
public void onPopulateScene(Scene pScene,
        OnPopulateSceneCallback pOnPopulateSceneCallback)
        throws IOException {
    // TODO Auto-generated method stub
    pOnPopulateSceneCallback.onPopulateSceneFinished();
}
}

0 Answers0