Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "EGL_BAD_MATCH" in Android Studio emulator

Tags:

android

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.

like image 402
bogdy9912 Avatar asked Nov 19 '16 20:11

bogdy9912


2 Answers

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)

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. enter image description here.

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.

like image 183
Uddhav P. Gautam Avatar answered Oct 02 '22 21:10

Uddhav P. Gautam


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.

like image 32
user3879096 Avatar answered Oct 02 '22 22:10

user3879096