20

enter image description here

Error:Could not open initscript class cache for initialization script 'C:\Users\Avishek\AppData\Local\Temp\asLocalRepo14.gradle' (C:\Users\Avishek.gradle\caches\2.2.1\scripts\asLocalRepo14_dkwbdtenxxgt2q2wfe57wj30b\InitScript\initscript). java.io.FileNotFoundException: C:\Users\Avishek.gradle\caches\2.2.1\scripts\asLocalRepo14_dkwbdtenxxgt2q2wfe57wj30b\InitScript\initscript\cache.properties (The system cannot find the file specified)

This error gives when I want to rebuild a project or clean project or run project.

Please someone help me...Thank you...

Avishek Das
  • 661
  • 1
  • 6
  • 20

7 Answers7

32

Don't use Gradle with a fresh version of JDK. It may not support it. In my case, downgrading JDK solved the issue.

Jan Bodnar
  • 10,969
  • 6
  • 68
  • 77
  • This Answer should be accepted! It worked for me – Arun K Babu Oct 23 '21 at 17:48
  • Same. Upvoting . The problem is indeed occuring only with JDK 17 for me, downgrading to JDK 15 worked . I got it for a fresh compose-desktop app created with IntelliJ Idea. – Ovi Trif Apr 12 '22 at 21:30
8

You should delete "scripts" folder from "C:\Users\user.gradle\caches\2.4\" via this answer. Then refresh gradle from Android Studio. This worked for me.

Community
  • 1
  • 1
Sirojiddin Komolov
  • 771
  • 10
  • 17
  • 1
    I delete the "2.2.1" from "C:\Users\user.gradle\caches\". Then I restart the Android Studio. That's works for me... – Avishek Das Oct 18 '15 at 06:59
1

You may have opened Android Studio twice. In that case close one of the instances and click on Try Again or Synchronize Gradle, or restart Android Studio. It is because the gradle build was not completed and other dependencies like classpath did not initialize at startup.

Andriy M
  • 76,112
  • 17
  • 94
  • 154
jude nneji
  • 21
  • 3
1

2022 New Answer for Kotlin base projects

  1. Open IntelliJ IDEA CE
  2. Click Create New Project or File/New/Project

Important !!!

  1. Select Kotlin from left side of window.
  2. Select IntelliJ in Build System.
  3. Click Next.
  4. Done. You will not have this error when you run your Kotlin file in the IDE.

enter image description here

canerkaseler
  • 6,204
  • 45
  • 38
  • This worked for me, I think there is a problem with the Graddle Build System esp if you are using JDK Version 20. – Tonnie Jul 08 '23 at 15:45
0

You should check android studio power save menu in file. If it was previously selected, then it should be unselected the power save mode in android studio in file menu. I hope it will be worked.

Md. Maidul Islam
  • 564
  • 6
  • 10
0

In my case I have deleted .gradle folder and clean the project on re run the project was working fine.

enter image description here

Anand Kumar Jha
  • 614
  • 9
  • 23
0
  1. Close the android studio

  2. Delete this file from your pc C:\Users\Avishek\AppData\Local\Temp\asLocalRepo14.gradle

  3. Delete folder from your pc C:\Users\Avishek.gradle\caches\2.2.1

  4. Your app in .gradle and .idea file is also delete

  5. And start your android studio