Gradle "java.lang.NoClassDefFoundError" after clean build

I am upgrading my current Gradle from 3.5.1 to 4.1, and when I usually do ‘gradlew clean build’ to clear certain directories.

Whenever I upgraded and ran the first time, the ‘gradlew clean build’ was successful. However on another attempt of ‘gradlew clean build’, I would get


for all the methods in API call. And in order to get another successful clean build, I must find the java process and kill it and try again, but I did not have to do that for 3.5.1?

Edit: So, if I call ‘gradlew clean’ and ‘gradlew build’, it will be successful even when there is an existing process. So why does ‘gradlew clean build’ does not act the same way?