Gradle dependency does not exist



Hoping to get some help on a weird issue I'm having. I've created a simple Gradle project and tried to add a dependency to build.gradle, but IntelliJ on Windows claims the package doesn't exist. I've synced the Gradle project, and the dependency (Google Gson) appears in the External Libraries section and in the module dependencies. IntelliJ even auto completes and imports the classes when I attempt to use them in the project. But when I run the project, I get:

"java: package does not exist"

I've tried importing this same project to the Mac version of IntelliJ with the same settings, and it runs just fine. Is there something I need to do to get this to run on the Windows versionas well? Thanks.


Please try File | Invalidate Caches | Invalidate and Restart.

If the issue remains, please provide a sample project illustrating the problem and the exact steps to reproduce.


 Thanks for the reply. Invalidate Caches did not work for me. Here's a link to the simplest project I can imagine:

One added Gradle dependency, one Main file. Just add an Application run configuration with the "app_main" module selected and the "Main" class selected to run. Again, this works just fine on my Mac, but does not on my Windows machine.


Sorry, not reproducible for me on Windows:

Try to enable debug logging for build.log and provide both idea.log and build.log files after Rebuild:


Logs are available here:

Also including a screenshot similar to yours for comparison:

Thanks for your continued assistance!


It doesn't look like you've enable debug logging for build.log. Please double check.

Also attach .idea directory and .iml file generated by IDEA from Gradle for this project.

Can you confirm that `gradle compileJava` succeeds from the command line?


Sorry about that, should be working now:

.idea directory is included as well. The only .iml files in the project are in that folder. Executing "gradle compileJava" seems to work.


Could be the cache issue with "D:\Jason\.gradle\caches\modules-2\files-2.1\\gson\2.6.2\f1bc476cc167b18e66c297df599b2377131a8947\gson-2.6.2.jar" file. Please try to remove it, then reimport the project and let Gradle fetch the fresh copy.


This is definitely the issue. The folder doesn't even exist. I have folders for versions 2.3 and 2.3.1 in the cache from older projects, but 2.6.2 does not exist. Switching to 2.3.1 allows me to build, since it finds that cached version. However, I can't seem to generate any new folders. I've tried refreshing the Gradle project and importing it as new, both with and without deleting the Gson folder from the cache, but nothing so far. How can I get this to resolve?


Forcing redownload and even deleting the cache entirely would not work. You set me on the right track, though- turns out I had two different Gradle caches, something that came from having Android Studio installed first. They were getting crossed up, but now I have them all cleaned and working. Thanks for all your help, Serge!


Please sign in to leave a comment.