Gradle “Could not resolve all dependencies for configuration ‘:classpath’.”

Running a gradle project, you may encounter the error below. In my case it occurs after the gradle project crashed, requiring a restart.

Error message:

>Could not resolve all dependencies for configuration ':classpath'.
 >Could not load module metadata from /home/username/.gradle/caches/modules-2/metadata-2.97/descriptors/io.netty/netty-common/4.1.23.Final/671a8ecc284f9e9f4d35b614eb5de66e/descriptor.bin

Solution:

You need to delete the cache

cd /home/username/.gradle
rm -r caches