To create the buttons used the library FButton . Then he tried to add a listener to him through the Butter Knife, did not work.

@OnClick(R.id.startButton) 

Then I tried to create a button object and give it to the listener. The same did not work.

 FButton btn = (FButton)findViewById(R.id.startButton); View.OnClickListener btnClick = new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(context, MenuActivity.class)); } }; btn.setOnClickListener(btnClick); 

It did not help, the button does not respond (

  • btn is always null - manGust
  • If btn is null, then you have something wrong in the markup / code. Check that you have the same button ID in the markup / code. That you uploaded the correct markup. - Yuriy SPb
  • If you haven’t solved the problem yet, lay out your onCreate with Butter - Shwarz Andrei
  • Thank you @ YuriSPb. Noticed that did not use setContentView. Accidentally deleted. Most likely something would have turned out, only now there was an incomprehensible error. Error: Execution failed for task ': app: mergeDebugResources' .- 1 Blush on "R.". Tried to make a "Clean project", but this error or Error: Execution failed for task ': app: mergeDebugResources'. > java.lang.ArrayIndexOutOfBoundsException (no error message) I can not clean , rebuild too ( - manGust
  • @manGust, maybe you have something wrong in the dependencies. Try to lower them. You probably have almost all 24 versions of everything. - Yuriy SPb

1 answer 1

Removed setContentView by inattention. He coped with the error simply. Removed everything from the libraries directory, then Sync Project and Clean Project. The problem disappeared, the buttons work. But butter knife, by @OnClick () still refuses to work.