Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 code example

Example 1: Could not initialize class org.codehaus.groovy.vmplugin.VMPluginFactory

On your Android or Intellij Project, go to:

yourprojectname/gradle/wrapper/gradle-wrapper.properties. 
Property distributionUrl should be: 

distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip

If it's an older version then change it, run ./gradlew clean build and try again.

Example 2: Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

Add the following lines to your $HOME/.bash_profile or $HOME/.bashrc (if you are using zsh then ~/.zprofile or ~/.zshrc) config file:
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"

Tags:

Java Example