Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java project with Gradle in IntelliJ IDEA: cannot resolve symbol 'google' but project compiles

I have a toy Java project set up with Gradle in IntelliJ IDEA 13.1.2. It compiles and runs fine, but the IDE highlights 'google' in

import com.google.common.base.Strings; 

as red and warns "Cannot resolve symbol 'google'". Any idea how to fix it?

I have tried 1) deleting .idea/ and re-creating the project in IntelliJ IDEA, and 2) re-importing project from the manually created Gradle configuration file build.gradle, but to no avail.

like image 225
Meng Lu Avatar asked Jul 06 '14 22:07

Meng Lu


People also ask

How does IntelliJ recognize Gradle project?

Navigate to the build.In the Gradle tool window, right-click a linked project. From the context menu, select Open Gradle config F4 . IntelliJ IDEA navigates to the appropriate Gradle configuration file and the related build. gradle file opens in the editor.

How do I mark a project as Gradle in IntelliJ?

Open your project in IntelliJ IDEA. In the Project tool window, right-click the name of your project and select New | File. In the dialog that opens enter build. gradle and click OK.


1 Answers

I think user Sap is correct, at least in my case. You should not have to manually add the dependency.

Did you change the dependencies in the gradle file without syncing intellij? Try this button:

screenshot of sync button

For more information, see: https://www.jetbrains.com/idea/help/synchronizing-changes-in-gradle-project-and-intellij-idea-project.html

like image 66
forestj Avatar answered Sep 30 '22 18:09

forestj