在Android Studio模拟器中出现“EGL_BAD_MATCH”错误

时间:2021-11-01 15:22:54

I have one question, what is that?

我有一个问题,那是什么?

E/EGL_emulation: tid 3912: eglSurfaceAttrib(1146): error 0x3009 (EGL_BAD_MATCH)

what should I do to resolve that error?

我该怎么解决这个错误呢?

public class Main extends AppCompatActivity {

public TextView score;
public ImageView alergator1;
public ImageView alergator2;
public FrameLayout frame;
public int scoreINT;
public float frameHigh;
public float frameWidh;
public float alergator1X;
public float alergator1Y;
public float alergator2X;
public float alergator2Y;
public ImageView miscare;
public int x;

private Handler handler = new Handler();
private static Timer timer = new Timer();



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    score = (TextView) findViewById(R.id.Score);
    alergator1 = (ImageView) findViewById(R.id.runner);
    alergator2 = (ImageView) findViewById(R.id.runner2);
    frame = (FrameLayout) findViewById(R.id.Frame);


    frame.post(new Runnable() {
        @Override
        public void run() {
            frameHigh = frame.getHeight();
            frameWidh = frame.getWidth();
        }
    });

    alergator1.post(new Runnable() {
        @Override
        public void run() {
            alergator1X = frameWidh / 2;
            alergator1.setX(alergator1X);
            alergator1Y = frameHigh - 250;
            alergator1.setY(alergator1Y);
        }
    });


    alergator2.post(new Runnable() {
        @Override
        public void run() {
            alergator2X = frameWidh / 2;
            alergator2.setX(alergator2X);
            alergator2Y = frameHigh - 250;
            alergator2.setY(alergator2Y);
        }
    });


    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    x++;
                    if (x % 2 == 0) {
                        alergator1.setVisibility(View.INVISIBLE);
                        alergator2.setVisibility(View.VISIBLE);
                    } else {
                        alergator2.setVisibility(View.INVISIBLE);
                        alergator1.setVisibility(View.VISIBLE);

                    }

                }
            });

        }
    }, 0, 900);

That is the code, the app runs correctly, but I want to know what is happening. Maybe my code is disorderly, but I am a beginner.

这是代码,应用程序运行正确,但我想知道发生了什么。也许我的代码有点乱,但我是一个初学者。

2 个解决方案

#1


4  

EGL means Emulated Graphics Library. The Android mobile device operating system uses EGL for 3D graphics rendering. Get more knowledge on EGL from wiki: https://en.wikipedia.org/wiki/EGL_(API)

EGL表示仿真图形库。Android移动设备操作系统使用EGL进行3D图形渲染。从wiki获取更多关于EGL的知识:https://en.wikipedia.org/wiki/EGL_(API)

When it says EGL_BAD_MATCH, your Emulated Graphics Library is which you/system selected is bad. There are two EGL modes as shown in below pic. 在Android Studio模拟器中出现“EGL_BAD_MATCH”错误.

当它说EGL_BAD_MATCH时,您的仿真图形库是您/系统选择的错误。如下图所示有两种EGL模式。

Solution: Which mode is giving problem, just change to another mode, it should fix. Be aware that running in software emulation mode may run considerably slower than with hardware emulation mode set. There are cases where errors are thrown (shown) yet the app runs okay. If this is the case, you may want to ignore the errors and enjoy the superior graphics emulation.

解决方案:哪一种模式有问题,只要换另一种模式就可以了。请注意,在软件仿真模式下运行可能比在硬件仿真模式下运行慢得多。如果是这样,您可能想要忽略错误并享受更好的图形仿真。

#2


1  

I have also experienced a similar problem, I tried a simple sample app and it shows this error. In my case, I turned off android studio's instant run feature and it disappear. I don't know why but you can give a try.

我也遇到过类似的问题,我尝试了一个简单的示例应用程序,它显示了这个错误。在我的例子中,我关掉了android studio的即时运行功能,它就消失了。我不知道为什么,但你可以试试。

#1


4  

EGL means Emulated Graphics Library. The Android mobile device operating system uses EGL for 3D graphics rendering. Get more knowledge on EGL from wiki: https://en.wikipedia.org/wiki/EGL_(API)

EGL表示仿真图形库。Android移动设备操作系统使用EGL进行3D图形渲染。从wiki获取更多关于EGL的知识:https://en.wikipedia.org/wiki/EGL_(API)

When it says EGL_BAD_MATCH, your Emulated Graphics Library is which you/system selected is bad. There are two EGL modes as shown in below pic. 在Android Studio模拟器中出现“EGL_BAD_MATCH”错误.

当它说EGL_BAD_MATCH时,您的仿真图形库是您/系统选择的错误。如下图所示有两种EGL模式。

Solution: Which mode is giving problem, just change to another mode, it should fix. Be aware that running in software emulation mode may run considerably slower than with hardware emulation mode set. There are cases where errors are thrown (shown) yet the app runs okay. If this is the case, you may want to ignore the errors and enjoy the superior graphics emulation.

解决方案:哪一种模式有问题,只要换另一种模式就可以了。请注意,在软件仿真模式下运行可能比在硬件仿真模式下运行慢得多。如果是这样,您可能想要忽略错误并享受更好的图形仿真。

#2


1  

I have also experienced a similar problem, I tried a simple sample app and it shows this error. In my case, I turned off android studio's instant run feature and it disappear. I don't know why but you can give a try.

我也遇到过类似的问题,我尝试了一个简单的示例应用程序,它显示了这个错误。在我的例子中,我关掉了android studio的即时运行功能,它就消失了。我不知道为什么,但你可以试试。