0

When I'm debugging my app all works, but when I build APK (Debug, release, signed..) it crashes after I press the button.

My onClick method:

protected void Click(View V) {
    Toast.makeText(this, "Hi!", Toast.LENGTH_SHORT).show();
}

Button XML:

<Button
    android:id="@+id/btnSpy"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:onClick="Click"
    android:text="Activate"
    android:textAllCaps="false"
    tools:layout_editor_absoluteX="148dp"
    tools:layout_editor_absoluteY="212dp" />

EDIT: Sorry forgot to change Spy to Click

  • 1
    A stacktrace from the crash might be useful. In short there isn't enough info here to help you. – tantalum Mar 22 '17 at 21:49
  • Compare your method names in xml and in Java. And, yes, please post stacktraces from your crashes when you need help. – codeMagic Mar 22 '17 at 21:55

1 Answers1

0

Simply change protected to public and change onClick="Spy" to onClick="Click"