Android Studio Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
Solution 1
I faced this issue because of lower version of Jdk. Previously I installed Jdk 1.7 and Android Studio 1.5.1, I got this issue. If you install Android Studio 1.5.1 or above JDK 1.8 required
So Installing JDK 1.8 solved this issue.
Solution 2
Please make changes as per below to resolve this error.
Install Java SDK version: 14 or above.
JDK Download link: https://www.oracle.com/java/technologies/javase-jdk14-downloads.html
In
gradle-wrapper.properties
please use grade version 6.3 or above.
For e.g:distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
Solution 3
-
This is because of the gradle version.
-
Go to:
gradle/wrapper/gradle-wrapper.properties
. -
Change a version of the course by this:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
The console outputs:
Welcome to Gradle 6.3!
Here are the highlights of this release:
- Java 14 support
- Improved error messages for unexpected failures
For more details see https://docs.gradle.org/6.3/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
Solution 4
First watch this and try reinstall - https://youtu.be/trHinrIm6DM
After if you get "Could not initialize class org.codehaus.groovy.runtime.InvokerHelper"
1.install Java SDK 14 and update env path.
2."[Your RN or Flutter Project Folder]\android\gradle\wrapper\gradle-wrapper.properties" this file edit as ...(upgrade gradle version)
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
3.run gradlew in cmd path "[Your RN or Flutter Project Folder]\android\"
4.it takes time.after if shows "BUILD SUCCESSFUL" you can "flutter run" in ur project folder
Yeah It's work 👍
Solution 5
What was helpful for me (MacBook):
- first go to File -> Invalidate Caches / Restart -> Invalidate and Restart
- then check the value of JAVA_HOME enviroment variable, by calling
echo $JAVA_HOME
(it should be equal to "/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home") - if it is not, change its value by calling
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
Related videos on Youtube
Comments
-
sm_ 5 months
I am new in Android Studio. After setup, When I am trying to import an application I am getting that error So that gradle not able to build.
Error:Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
I checked that my classpath setting for Java is fine. I am running Windows OS. Does anyone know the source of the error?
-
Paul almost 7 yearsDid you check your "JAVA_HOME" variable?
-
-
Bruno de Oliveira over 2 yearsUpdating the Gradle from 6.0.1-all to 6.3-all solved the problem on Mac OS Catalina, tks. React-native build by the way.
-
Fathi Osama over 2 yearsThanks a lot, i couldnt find a solution anywhere else.
-
Abhimanyu Rathore over 2 yearsI was beginner in react native and was scratching my head from so long to run Android device !! .Y ou are amazing Man !!! you saved my time and thanks that you have a great attitude to help others like this clean information !!
-
Riley Fitzpatrick over 2 yearsI am using Java 14. with Gradle 6.4 but the problem still exists for me.
-
Jeaf Gilbert over 2 yearsBEST ANSWER, why is this not included in the ReactNative init.
-
Maher Abuthraa over 2 yearsthis worked with me "distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip"
-
Chagai Friedlander over 2 yearsthanks, this really helped me! why is this happening? could I use a lower gradle version(perhaps also a lower java version) and still get it to work?
-
Spikatrix over 2 yearsSwitching to Java 8 worked for me (I didn't have 11 installed). Thanks!
-
Michael Ashefor over 2 yearscommand should be ./gradlew not gradlew . Everything else works fine
-
Mohammad over 2 yearshow about the old projects? with distribution 5.~.zip and jdk 14
-
locropulenton over 2 yearsThanks! This works for me given that I am in a react native project and JAVA 14 / Open JDK!
-
Mahad Ahmed about 2 yearsI'm on
java version "15" 2020-09-15
and this worked for me on MacOS Catalina. -
Ahmed Elshaer about 2 yearsThis is actually worked with me without the need to update wrapper version, the case that I did a fresh install on my macOS and installed a lot of things and this could have changed the JAVA_HOME and cause this issue, thanks a lot
-
dilantha111 about 2 yearsThanks this helped. Not sure why this was not yet selected as the accepted answer.
-
VtoCorleone about 2 yearsWelcome to Stackoverflow and great contribution!
-
Shariful Islam Mubin about 2 yearsSuper! Works like a charm in Flutter!!
-
sudonitin about 2 yearsThis worked for me. But it sort of gets reset on every bootup. How can I make this change permanent?
-
Soumya Boral about 2 yearswhere can I get gradle-wrapper.properties file please ?
-
bongtoi about 2 yearsYou can get it at path "YOUR_PROJECT/gradle/wrapper/gradle-wrapper.properties"
-
Pradap Pandian about 2 yearsThis saved my life
-
jakub-adamczewski about 2 yearsHey @sudonitin, check there to see how to save enviroment variables permanently: medium.com/@youngstone89/…
-
Anchal Ajay about 2 yearsUpdating the Gradle from 5.6.2-all to 6.5-all solved the problem on Windows, For Flutter
-
dılo sürücü almost 2 yearsswitched 11 version and worked for me (pop-os)
-
dragon788 almost 2 yearsThis is huge because you DO NOT have to go through the trouble of installing Java if you have Android Studio. See also stackoverflow.com/a/48957460 for shell config to set some things automatically.
-
Shivam Jha over 1 year
-
Mike S. over 1 yearI did the same. In my case, it didn't fix the issue.
-
Mike S. over 1 yearThis is the same answer that @josileudo provided.
-
Mike S. over 1 yearFor react native, it's slightly different:
YOUR_PROJECT/android/gradle/wrapper/gradle-wrapper.properties
-
negrotico19 over 1 yearThis is not working for me because the Path Please set the JAVA_HOME variable in your environment to match the location of your Java installation., However following this link: stackoverflow.com/a/19663996/4696051 allowed me to find the correct Java Home Path in MacOs Catalina /usr/libexec/java_home
-
Pentagura over 1 yearThank you, you save my live
-
anie over 1 yearyou saved my day, just for me required a further step which is rebuild gradle in android studio in mac OS.
-
Umer Waqas Flutter Developer over 1 yearexport JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"