6

我正在尝试使用AndEngine 教程在 android 中制作简单的游戏

现在,当我运行该项目时,我收到错误消息说java.lang.IllegalArgumentException: No EGLConfig found!

TowerOfHanoiActivity.java

public class TowerOfHanoiActivity extends SimpleBaseGameActivity {

    private static int CAMERA_WIDTH = 800;
    private static int CAMERA_HEIGHT = 480;
    private ITextureRegion mBackgroundTextureRegion, mTowerTextureRegion,
            mRing1, mRing2, mRing3;

    @Override
    public EngineOptions onCreateEngineOptions() {

        final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);

        return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED,
                new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
    }

    @Override
    protected void onCreateResources() {

        try {

            // 1 - Set up bitmap textures
            ITexture backgroundTexture = new BitmapTexture(
                    this.getTextureManager(), new IInputStreamOpener() {

                        @Override
                        public InputStream open() throws IOException {
                            return getAssets().open("gfx/background.png");
                        }
                    });

            ITexture towerITexture = new BitmapTexture(
                    this.getTextureManager(), new IInputStreamOpener() {

                        @Override
                        public InputStream open() throws IOException {
                            return getAssets().open("gfx/tower.png");
                        }
                    });

            ITexture ring1 = new BitmapTexture(this.getTextureManager(),
                    new IInputStreamOpener() {

                        @Override
                        public InputStream open() throws IOException {
                            return getAssets().open("gfx/ring1.png");
                        }
                    });
            ITexture ring2 = new BitmapTexture(this.getTextureManager(),
                    new IInputStreamOpener() {

                        @Override
                        public InputStream open() throws IOException {
                            return getAssets().open("gfx/ring2.png");
                        }
                    });
            ITexture ring3 = new BitmapTexture(this.getTextureManager(),
                    new IInputStreamOpener() {

                        @Override
                        public InputStream open() throws IOException {
                            return getAssets().open("gfx/ring3.png");
                        }
                    });

            // 2 - Load bitmap textures into VRAM

            backgroundTexture.load();
            towerITexture.load();
            ring1.load();
            ring2.load();
            ring3.load();

            // 3 - Set up texture regions
            this.mBackgroundTextureRegion = TextureRegionFactory.extractFromTexture(backgroundTexture);
            this.mTowerTextureRegion = TextureRegionFactory.extractFromTexture(towerITexture);
            this.mRing1 = TextureRegionFactory.extractFromTexture(ring1);
            this.mRing2 = TextureRegionFactory.extractFromTexture(ring2);
            this.mRing3 = TextureRegionFactory.extractFromTexture(ring3);

        } catch (IOException e) {
            Debug.e(e);
        }

    }

    @Override
    protected Scene onCreateScene() {
        
        // 1 - Create new scene
        final Scene scene = new Scene();
        Sprite backroundSprite = new Sprite(0, 0, this.mBackgroundTextureRegion, getVertexBufferObjectManager());
        scene.attachChild(backroundSprite);
        return scene;
    }

}

日志猫:

03-28 15:21:17.957: D/AndEngine(1478): TowerOfHanoiActivity.onCreate @(Thread: 'main')
03-28 15:21:17.997: D/dalvikvm(1478): Trying to load lib /data/data/com.tutorial.towerofhanoi/lib/libandengine.so 0xb67ac4e0
03-28 15:21:18.007: D/dalvikvm(1478): Added shared lib /data/data/com.tutorial.towerofhanoi/lib/libandengine.so 0xb67ac4e0
03-28 15:21:18.007: D/dalvikvm(1478): No JNI_OnLoad found in /data/data/com.tutorial.towerofhanoi/lib/libandengine.so 0xb67ac4e0, skipping init
03-28 15:21:18.127: D/AndEngine(1478): TowerOfHanoiActivity.onResume @(Thread: 'main')
03-28 15:21:18.277: D/libEGL(1478): Emulator without GPU support detected. Fallback to software renderer.
03-28 15:21:18.277: D/libEGL(1478): loaded /system/lib/egl/libGLES_android.so
03-28 15:21:18.317: W/dalvikvm(1478): threadid=11: thread exiting with uncaught exception (group=0xb615e180)
03-28 15:21:18.328: E/AndroidRuntime(1478): FATAL EXCEPTION: GLThread 81
03-28 15:21:18.328: E/AndroidRuntime(1478): java.lang.IllegalArgumentException: No EGLConfig found!
03-28 15:21:18.328: E/AndroidRuntime(1478):     at org.andengine.opengl.view.ConfigChooser.chooseConfig(ConfigChooser.java:183)
03-28 15:21:18.328: E/AndroidRuntime(1478):     at org.andengine.opengl.view.ConfigChooser.chooseConfig(ConfigChooser.java:157)
03-28 15:21:18.328: E/AndroidRuntime(1478):     at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1009)
03-28 15:21:18.328: E/AndroidRuntime(1478):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1362)
03-28 15:21:18.328: E/AndroidRuntime(1478):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
03-28 15:21:18.387: D/gralloc_goldfish(1478): Emulator without GPU emulation detected.
03-28 15:21:18.427: I/dalvikvm(1478): threadid=3: reacting to signal 3
03-28 15:21:18.437: I/dalvikvm(1478): Wrote stack traces to '/data/anr/traces.txt'
03-28 15:21:18.717: D/AndEngine(1478): TowerOfHanoiActivity.onPause @(Thread: 'main')
03-28 15:21:19.167: D/AndEngine(1478): TowerOfHanoiActivity.onDestroy @(Thread: 'main')
03-28 15:21:19.197: D/AndEngine(1478): UpdateThread interrupted. Don't worry - this EngineDestroyedException is most likely expected!
03-28 15:21:19.197: D/AndEngine(1478): org.andengine.engine.Engine$EngineDestroyedException
03-28 15:21:19.197: D/AndEngine(1478):  at org.andengine.engine.Engine.throwOnDestroyed(Engine.java:574)
03-28 15:21:19.197: D/AndEngine(1478):  at org.andengine.engine.Engine.onTickUpdate(Engine.java:560)
03-28 15:21:19.197: D/AndEngine(1478):  at org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)
03-28 15:21:19.197: D/AndEngine(1478): TowerOfHanoiActivity.onDestroyResources @(Thread: 'main')
03-28 15:21:19.197: D/AndEngine(1478): TowerOfHanoiActivity.onGameDestroyed @(Thread: 'main')
03-28 15:21:22.477: I/Process(1478): Sending signal. PID: 1478 SIG: 9

我正在使用以下设置在模拟器中测试我的应用程序

在此处输入图像描述

请给我一个适当的解决方案。谢谢

4

3 回答 3

4

使用 Target 4.0.3 -API 级别 15 和 GPU 仿真创建 AVD 是。我的示例说明在此之后运行。如果您还有其他问题,请访问AndEngine 论坛并获取有关 OpenGL 驱动程序的详细信息

于 2013-08-21T05:29:15.940 回答
1

我遇到了同样的问题,这在 Windows 7 64 位上对我有用。我的 AVD 设置是 Device : (800 x 480 hdpi), Target: Android 4.4 API Level 19, CPU/ABI: ARM (armeabi-v7a)。

  1. 我将内存选项更改为 512 VM Heap 32
  2. 然后是仿真选项并选中“使用主机 GPU”。
  3. 单击确定,刷新,清理项目,重新启动 Eclipse。
  4. 运行配置 -> Android -> 项目 -> 运行
于 2013-12-06T09:40:26.380 回答
0

你的模拟器配置没问题,尝试创建一个新的模拟器并运行这个可能运行的代码。如果没有,那么编码应该有问题

于 2013-03-28T10:42:14.873 回答