2

Android studio is failing to suggest imports for known classes, like Date and List and so on. Just warns "Cannot resolve symbol"

Android Studio 2.2.3
Build #AI-145.3537739, built on December 2, 2016
JRE: 1.8.0_76-release-b03 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Note: Auto import is enabled, and there are no excluded classes from it, manually adding the import statement works.

aclowkay
  • 3,577
  • 5
  • 35
  • 66
  • Does gradle give you errors? If it does, solve those first. Are there errors elsewhere in your app? If so, try to solve those first. – Christine Dec 10 '16 at 16:42

2 Answers2

9

It should automatically import (atleast in 2.2.2).Try this if it does not, Select the red coloured text ( the symbols which can't be resolved) and press Ctrl+i . This will import the required.

If this does not work go to File-> Invalidate caches/Restart.

Auto import not working for Android classes in Android studio

Community
  • 1
  • 1
Sivagami Nambi
  • 332
  • 4
  • 9
0

Invalidating caches didn't work for me.

What I found working was to tick the "Scope analysis to the current package" in the Dart Analysis.

enter image description here

NicklasF
  • 863
  • 3
  • 10
  • 26