Hi there I am new to Android Junit testing:
I have written some test code in MainActivityFunctionalTest.java file
MainActivityFunctionalTest.java:
It's because your device is locked/any other open dialog box is open /anything preventing the test's ability to click on the button. Eg. if the phone is locked-when the test tries to click on the button it can't because the device is locked.
I was having troubles on the emulator because it always displayed "launcher has crashed". So whenever it tried to click the button, it couldn't because the alert dialog box was open.
In short, make sure your screen is unlocked and no message boxes are interfering with the test and it's ability to click on a button.