Could not initialize class

I am running connectedCheck task on this project:

I get the following error:

FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:app:connectedDebugAndroidTest’.
Could not initialize class
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at

This project in Android Studio is being built with Gradle 4.2 and android gradle plugin 3.0.0-beta7. Does anybody know what is causing this?

UPDATE: the issue seems to be resolved with Gradle 4.3-rc-1. It is explained better in this Github post: