1

Why can't I use 'String' object in a Java class? It does not appear in the code suggestions.

enter image description here

I am getting this error: Cannot resolve symbol 'String'

enter image description here

leopal
  • 4,711
  • 1
  • 25
  • 35
  • Did you setup or select a JDK? – Glains Jan 15 '20 at 07:56
  • 3
    Does this answer your question? [Android Studio "cannot resolve symbol String"](https://stackoverflow.com/questions/23445233/android-studio-cannot-resolve-symbol-string) – Md. Asaduzzaman Jan 15 '20 at 07:56
  • @Glains yes i did – Fredyka Maulana Jan 15 '20 at 07:58
  • @Md.Asaduzzaman i already to try invalidate and restart, but can't resolve teh problem – Fredyka Maulana Jan 15 '20 at 08:00
  • 2
    what about building? can you build the project with this error? if you can, the problem is with your IDE and you need to remove the IDE and all its configurations and install it again – Mohsen Jan 15 '20 at 09:36
  • @mohsen when i try build this project the result is complete successfully. it's mean your prediction maybe all right. and thanks for your advice – Fredyka Maulana Jan 15 '20 at 09:57
  • you're welcome, check this out [how-to-completely-uninstall-android-studio-from-windows](https://stackoverflow.com/questions/39953495/how-to-completely-uninstall-android-studio-from-windowsv10) – Mohsen Jan 15 '20 at 10:09
  • You can try by selecting the menu item File and click on Invalidate Caches/Restart This solution will work for some of the users not all – Rishab Surana Jun 23 '22 at 06:19

2 Answers2

0

It worked for me when I selected the correct JDK in Project Structure and Reloaded the project from disk (right click & the reload option is present)

  1. File > Project Structure
  2. Select JDK , Apply and OK
  3. Right click on project & the reload from disk enter image description here
Vidhya
  • 79
  • 2
  • 6
-2

Project Structure > Set proper JDK available version. The issue will be indexed.