Android AndEngine RenderSurfaceView NullPointerException

Android AndEngine RenderSurfaceView NullPointerException,android,xml,andengine,Android,Xml,Andengine,我在menu_layout.xml文件中得到一个NullPointerException。为了使用EditText,我正在扩展一个LayoutGameActivity类。在这里发布之前,我已经在谷歌上搜索了很多东西,但没能成功修复。我也像一些建议一样更新了ADT,但什么都没有 menu_layout.xml错误日志: java.lang.NullPointerException Couldn't resolve resource @id/gameSurfaceView Exception det

我在menu_layout.xml文件中得到一个NullPointerException。为了使用EditText,我正在扩展一个LayoutGameActivity类。在这里发布之前,我已经在谷歌上搜索了很多东西,但没能成功修复。我也像一些建议一样更新了ADT,但什么都没有

menu_layout.xml错误日志:

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

上述代码在我的设备测试Nexus 4中非常有效,但我使用的是AnEngine GLES 2 AnchorCenter。我尝试使用AnEngine GLES 2 AnchorCenter,其工作:-您可以在AnEngine GLES 2 AnchorCenter示例中尝试XMLLayoutExample吗?是的,它可以与RelativeLayout一起工作。只是在xml图形视图上显示了错误。
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();
}
}