简体   繁体   中英

Could not initialize class org.codehaus.groovy.reflection.ReflectionCache

I've been using Flutter on Android Studio. Today, I updated it and everything went downhill.

I've been having different errors throughout my attempt to fix this.

First error: could not initialize class org.codehaus.groovy.runtime.invokerhelper

Second error: could not initialize class org.codehaus.groovy.reflection.ReflectionCache

在此处输入图片说明

Anyways, I've been researching and I've done the following

  1. Updated Java SDK.
  2. Updated JRE
  3. Added necessary paths to environment variables
  4. Updated Gradle

But nothing is still working and I cannot run my project. Please help?

Here are some screenshots of my different attempts: 在此处输入图片说明 在此处输入图片说明 在此处输入图片说明

在此处输入图片说明

I had the same problem a few days ago. I fixed it by updating the Gradle version in android/gradle/wrapper/gradle-wrapper.properties to :

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

For it to update, you just have to flutter run .

I finally fixed it by uninstalling anything beyond Java 8. It seems like Android Studio doesn't like upgraded Java. Everything works now.

I fixed it by updating gradle version.

  1. Go to android->gradle->wrapper->gradle-wrapper.properties file and update gradle to latest version.

     distributionUrl=https\\://services.gradle.org/distributions/gradle-6.7.1-all.zip
  2. Go to android->build.gradle file

     classpath 'com.android.tools.build:gradle:4.2.0'
  3. flutter clean

  4. flutter run

  1. Do you get any error when you run

flutter doctor 

in terminal.

  1. Did you run

flutter clean

in terminal from your project folder?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM