14

I am new to Android Studio and I keep getting this error. I have researched and tried deleting .gradle, closing program and restarting, checking power save mode, and Cleaning and Rerunning. Any other ideas to try would be greatly appreciated. It worked perfect last night and now I am getting this error.

Error:Could not open cp_init class cache for initialization script 'C:\Users\Owner\AppData\Local\Temp\asLocalRepo6.gradle' (C:\Users\Owner.gradle\caches\2.10\scripts\asLocalRepo6_4rdykqo5vjpjfhlk1g3pwkx76\cp_init).

java.io.FileNotFoundException: C:\Users\Owner.gradle\caches\2.10\scripts\asLocalRepo6_4rdykqo5vjpjfhlk1g3pwkx76\cp_init\cache.properties (The system cannot find the file specified)

Thanks!

Brittany
  • 141
  • 1
  • 1
  • 5

8 Answers8

22

You might also be running a too-new version of Java. Downgrading to Java 1.8 via https://adoptopenjdk.net/ fixed this issue for me.

See BUG! exception in phase 'semantic analysis'

bobmagoo
  • 358
  • 2
  • 8
10

Set the Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM to "Use Internal JRE (java version 11-ea+123"....)

https://youtrack.jetbrains.com/issue/KT-34134

enter image description here

VilasKolhe
  • 121
  • 1
  • 2
4

I had this same problem sometimes ago. This is my solution

  1. Click on File menu and
  2. Select Invalidate Cache/Restart
  3. Select Invalidate and Restart
John
  • 71
  • 1
  • 7
2

Quick and dirty solution is to open C:\Users\%USER_NAME% or wherever your user directory is found, go in to \.gradle and delete the caches file

Felix Oje
  • 83
  • 2
  • 8
2

I fixed this error by downgrading Gradle Settings to Java 1.8:

enter image description here

julianm
  • 2,393
  • 1
  • 23
  • 24
0

Maybe you have opened your android project from wrong destination

I opened my project from "app" folder so I got this error

enter image description here

But when I opened my android project from "template" folder it's solved my problem.

enter image description here

Arjun Yadav
  • 101
  • 1
  • 6
0

The issue for me was that I was using different SDK for Java and Gradle in my intellij. Just make sure that the jdk used by Java is same as for Gradle

  1. Check Java SDK

Settings (Icon Top Right Corner) >> Project Structure >> Project Settings >> Project. Check your SDK here. enter image description here

  1. Check Gradle SDK

Settings >> Build , Execution & Deployement >> Build Tools >> Gradle Check JVM version here. Version in Java JDK and Gradle JVM should be same enter image description here

Ayush Tiwari
  • 91
  • 1
  • 8
0

I had to check the jdk version which my project uses. When I changed the JAVA home to an appropriate version (JDK 8) for my case. I didnt see this error.

pnagar
  • 41
  • 6