IntelliJ
IDE
troubleshooting
declarations
coding

IntelliJ "Cannot find declaration to go to" fixes

Codemia Knowledge Hub ·

When IntelliJ IDEA (or Android Studio) says it cannot find a declaration to go to, its index of the project is usually corrupted or out of date, or the project's SDK, modules or build-tool dependencies are misconfigured. Start with File > Invalidate Caches / Restart, then check the SDK and reimport Maven or Gradle.

Symptoms

  • Unresolved symbols: variables or methods are highlighted as unresolved even though they are declared correctly.
  • Broken navigation: Ctrl + Click and similar features cannot jump to declarations.
  • False errors: linting warnings and false-positive compilation failures appear.

Indexing and caching

IntelliJ builds indexes that map symbols to their declarations, and code completion, navigation and refactoring depend on them.

  • Index corruption: indexes can become corrupted or outdated, leaving references unresolved.
  • Memory limits: large projects can exhaust memory and stop IntelliJ from keeping indexes accurate.

Project configuration

  • Wrong SDK: an inappropriate SDK version can stop symbols from being recognized.
  • Misconfigured modules and libraries: missing or incorrect library paths prevent resolution.
  • Unrecognized file types: files with extensions IntelliJ does not recognize may not be indexed.

Dependency management

  • Build tool problems: errors in Maven, Gradle or SBT setup break dependency resolution.
  • Missing or broken pom.xml or build.gradle: IntelliJ cannot import dependencies without a correct build file.

Fixes

Rebuild the indexes

  1. Invalidate caches: go to File > Invalidate Caches / Restart.
  2. Rebuild indexes: this clears the existing indexes and restarts indexing.

Check the project structure

  • SDK: verify it under Project Structure > Project.
  • Module dependencies: review Project Structure > Modules.

Sync dependencies

  • Sync build scripts: run Maven > Reimport or Gradle > Refresh.
  • Review build files: make sure pom.xml, build.gradle or other build scripts are correct.

Check file types

  • File associations: verify them under Settings > Editor > File Types.

Other measures

  • More memory: edit idea.vmoptions to give IntelliJ more memory.
  • Update IntelliJ: newer versions include bug fixes and improved indexing.
  • Custom scripts: for large projects, scripts can simplify build and indexing.
AspectDescription
Indexing & CachingCore mechanism responsible for identifying declarations.
Configuration IssuesSDK and module setup errors lead to unresolved symbols.
Dependency ManagementMisconfigured dependencies impede symbol resolution.
Reindexing FixesOften resolves issues by clearing and rebuilding indexes.
Increasing MemoryEssential for large projects laden with symbols.
Maintaining IDE UpdatesReduces errors through regular updates and bug fixes.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Interview Questions practice on Codemia

Over 11,000 interview practice questions for 300+ companies, searchable by company and role.

Browse interview questions