Real Device: LG G2, android 4.4.2, OPENGL ES v3.0
Emulated Device: Nexus 5X, android 7.1.1, OPENGL ES v2.0 (Hardware)
Apps that involve modifying the views (setting text, making views visible/invisible, etc) run flawlessly on the emulator, but crash on the real device (on button press).
Apps that don't involve modifying any of these work fine on the real device.
I've tried it with this simple app:
(activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.cmnd97.test.MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="method"
android:text="Press me" />
</LinearLayout>
(MainActivity.java)
package com.cmnd97.test;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
protected void method() {
Button btn = (Button) findViewById(R.id.button);
btn.setText("Pressed");
}
}
This particular app crashes on button press without printing any error message to the debugger, however another app which involved hiding/showing a button printed this error:
Failed to set EGL_SWAP_BEHAVIOR error=EGL_BAD_MATCH
protected void method()
- This is a problem. When you specify anonClick
attribute in the layout, the method it refers to must bepublic
and have aView
parameter -public void method(View v)
. – Mike M. Mar 25 '17 at 21:33