176

I installed android studio.. it was working fine. Now all the sudden, none of the auto complete features are working.. I can type anything anywhere no variable checking, no help with functions or checking anything. I can still compile the project and I get errors when that happens.

Can anyone please help me out with this issue.

user2701882
  • 1,791
  • 2
  • 12
  • 8
  • Does this answer your question? [Android Studio marks R in red with error message "cannot resolve symbol R", but build succeeds](https://stackoverflow.com/questions/17421104/android-studio-marks-r-in-red-with-error-message-cannot-resolve-symbol-r-but) – Top-Master May 31 '22 at 02:12
  • Can be linked to kotlin gradle version , refer https://stackoverflow.com/a/68649643/14784590 – Reejesh Mar 06 '23 at 10:28

40 Answers40

264

#1 From Build menu (of your Android Studio), click Rebuild Project option.

#2 Then once rebuild completes, go to File > Invalidate Caches / Restart... and Click on Invalidate an Restart button.

enter image description here

enter image description here

This really works for me.

Source: https://code.google.com/p/android/issues/detail?id=61844#c4

#1 Rebuild is required, because Android-Studio does simply rely solely on Gradle's build-result (without static-analysis support, at least at time of writing, 2022).

#2 Clearing cache is required, because the previous build-result (before above rebuild) may be indexed, which makes Android Studio ignore latest Gradle build-result
(this is a very good speed optimization, but a very bad Developer-experience as well).

There can sometimes be other reasons too, which is why there are many other answers posted here.

Top-Master
  • 7,611
  • 5
  • 39
  • 71
Renan Franca
  • 3,438
  • 1
  • 18
  • 17
  • 6
    This works. You have to wait for the "indexing" process to finish. By the way, what's up with SO's answer sorting? This is clearly the best answer but it is below several bad copies of the power save mode answer (which doesn't work). – Timmmm Dec 03 '15 at 21:17
  • 3
    no longer working - A.S. 3.1.3 has suddenly stopped giving suggestions when editing XML ! – Someone Somewhere Jun 20 '18 at 14:39
  • If this does not work for you, try manually deleting the caches: see [this answer](https://stackoverflow.com/a/53388983/1689222). This helped in my case. – Pecan Jan 08 '20 at 10:06
  • Can confirm. This solution worked on Android Studio 4.1.3 – Ramakrishna Joshi Apr 09 '21 at 09:17
  • Yes, it will work after restart only for a short time. and again It will be gone. I have to restart every 15min to work with suggestions. – ÄR Âmmãř Żąîñh Jun 02 '21 at 01:42
  • Can confirm it also helps if you have automaticly hiding suggessions issue. – Egor Jul 26 '21 at 14:10
  • In my case it's not working. AS just suddenly [w/o any update etc] stopped suggesting code ... – Grzegorz Dev Oct 17 '22 at 09:21
  • This fix sometimes works, sometimes doesn't. This time it wasn't working, **but helped updating AndroidStudio**. – Grzegorz Dev Oct 17 '22 at 10:03
126

You can also check if Power Save Mode on File menu is disabled.

user2904931
  • 1,285
  • 1
  • 8
  • 3
70

Originally use:

compileSdkVersion 32
targetSdkVersion 32

And an update to 33 appeared, I updated it and the suggestions in the XML no longer appeared, I went back to 32 and now the suggestions appeared.

Erwin Martínez
  • 911
  • 4
  • 2
64
  1. Close Android Studio

  2. Go to C:\Users\UserName\.android and rename the folder:

    • build-cache to build-cache_old
  3. Go to C:\Users\UserName\.AndroidStudio3.x\system OR (for Android studio 4 and Higher) go to C:\Users\UserName\AppData\Local\Google\AndroidStudio4.x and rename these folders:

    • caches to caches_old

    • compiler to compiler_old

    • compile-server to compile-server_old

    • conversion to conversion_old

    • external_build_system to external_build_system_old

    • frameworks to frameworks_old

    • gradle to gradle_old

    • resource_folder_cache to resource_folder_cache_old

  4. Open Android Studio and open your project again.

SerjantArbuz
  • 982
  • 1
  • 12
  • 16
Sagar Makhija
  • 863
  • 8
  • 9
  • 2
    Works like a charm! "Invalidate and Restart" didn't work for me. By the way, for newer versions of Android Studio, the AndroidStudio folder is located at C:\Users\UserName\AppData\Local\Google\AndroidStudio4.1 – Tianyao 'Till' Chen Jan 14 '21 at 10:08
  • 1
    Thank you man, it's really work! Invalidate + restart was not enough, and I spend ~2 hour for find a solution. After renaming/removing this folders and opening project IDE starts indexing and everything become workable! – SerjantArbuz Jun 10 '21 at 12:20
  • this is the only working solution on SO for this problem. – Sadda Hussain Sep 01 '21 at 10:20
  • 1
    I closed Studio and deleted all folders named AndroidStudio in C:\Users\UserName\AppData\Local\Google\ fixed the issue. Thanks – Unaisul Hadi Sep 11 '21 at 05:39
  • 2
    Help! There is no `gradle` nor a `resource_folder_cache` in that location! (`C:\Users\karol\AppData\Local\Google\AndroidStudio2021.2`) Where could they be? – Karolina Hagegård Jun 24 '22 at 06:48
  • @KarolinaHagegård - for me it worked without deleting those folders – jrola Jan 01 '23 at 10:52
  • Linux users can find this folder under HOME/.cache/Google/AndroidStudio2021.3 (make sure you turn on show hidden files) – Reejesh Mar 06 '23 at 06:13
34
  1. Close Android Studio

  2. Go to c_users_path_on_windows/.AndroidStudio3.5/system/

  3. Delete the cache folder

  4. Start Android Studio

    This works for me.

zackygaurav
  • 4,369
  • 5
  • 26
  • 40
mili2501
  • 452
  • 5
  • 9
17

Most of the times i have seen that the problem is that Power Save Mode is enabled, to disable go to Current inspection profile (lower right corner in Android Studio).

enter image description here

bagage
  • 1,094
  • 1
  • 21
  • 44
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
14

I have not run into this problem personally, but try checking the following settings (File -> Settings or Alt+F7):

Project Settings [name]
Inspections - ensure that Android and Android Lint is checked, or alternately just set it back to default using the dropdown box at the top.

IDE Settings
Editor -> Code Completion - ensure the Autopopup code completion is checked (and check the rest of the settings based on your preference.

free3dom
  • 18,729
  • 7
  • 52
  • 51
11

Uncheck "Power Save Mode" in "File" tab

enter image description here

Muhammad Ali
  • 720
  • 8
  • 21
8

If nothing works (like happened with me ) go to your user profile in windows at %userprofile% . You will find folders there (hidden) named with the version of the android studio you are using and prefixed with a dot.

like .AndroidStudio3.1. Just delete that .

Muhammad Ahmed AbuTalib
  • 4,080
  • 4
  • 36
  • 59
7

Solution: Try disabling "File -> Power Save Mode" in Android Studio (Beta) 0.8.14 - Mac OS X

On windows, the option can be at some other place.


I had the same problem then I recalled that while exploring the new android studio, I switched on the "File -> Power Save Mode" to see what it does?

I disabled the power save mode and all those intelligent features were back.

It turned out that in Power Save Mode, Android Studio switches off the modules responsible for features like Smart Code Completion and Code Analysis.

Hasaan Ali
  • 1,192
  • 16
  • 22
7

I had a similar problem where none of the other solutions worked.

Closing Android Studio and then deleting the .idea and build folders resolved the issue.

Ben987654
  • 3,280
  • 4
  • 27
  • 50
7

For Artic Fox 2020|3.1 Version: Auto Complete Suggestion Problem.

Please Follow the Following Steps:

Close Android Studio

Locate caches folder in C:\Users{username}\AppData\Local\Google\AndroidStudio2020.3 and Delete it. Open Android Studio Again.

Check your Android studio version and Target that version folder at below location C:\Users{username}\AppData\Local\Google

Note : AppData folder is Hidden in Windows

This Solution also works if android studio mess up with xml files and java code. Don't! modify your code otherwise IDE won't able to change it to default. If you see such messy code just follow above steps and your code will be fine again.

waheed shah
  • 494
  • 7
  • 19
6

Disable Power Save Mode and Invalidate Cache and Restart.

enter image description here

Md Nakibul Hassan
  • 2,716
  • 1
  • 15
  • 19
5

It's Working

Disable Power Save Mode

Untick Power Save Mode Option :: File -> Power Save Mode

Nidheesh G
  • 67
  • 1
  • 2
4

Just remove all the folders named AndroidStudioPreview

On Windows:

Go to your User Folder - on Windows 7/8 this would be:

[SYSDRIVE]:\Users[your username] (ex. C:\Users\JohnDoe)

In this folder there should be a folder called .AndroidStudioPreview

On Mac OS X

Remove these files:

~/Library/Application Support/AndroidStudioPreview ~/Library/Caches/AndroidStudioPreview ~/Library/Logs/AndroidStudioPreview ~/Library/Preferences/AndroidStudioPreview

Lucky
  • 16,787
  • 19
  • 117
  • 151
jkin8010
  • 49
  • 2
4

There is a power saver mode in android studio if accidentally you click on that it will disable code analysis which will reduce the battery consumption and performance will also increase but it will not detect any errors and do auto complete operations.

To disable power saver mode

- Go to File Menu of Studio
- Uncheck The Power Saver Mode

In your IDE code analysis will be shown using an eye symbol at the right corner of your android studio.

If Green means it is enabled and there is no error in your code.
If Red Means It is enabled but there are few errors in your code.
If It is white or blur then code analysis is disabled
smali
  • 4,687
  • 7
  • 38
  • 60
  • 1
    Green check means there are no errors. Yellow square means there are warnings. Red square means there are errors. White eye means it's in progress. White pause icon means it's waiting on an autocomplete window to close. There's another white icon that means it's in power save mode and is disabled. – Anubian Noob Jul 11 '15 at 23:50
4

It worked for me. From menu select:

File -> Power Save Mode

and make sure it's disabled

Rehan Khan
  • 1,031
  • 13
  • 10
3

There can be several things which cause this.

  1. Make sure you've write the correct version in targetSdkVersion and compileSdkVersion.
  2. Make sure targetSdkVersion and compileSdkVersion are same.

Other solutions can be:

  1. Invalidate caches & restart Android Studio from FileInvalidate Caches / Restarts...
  2. Clean your project from BuildClean Project
  3. Rebuild project from BuildRebuild Project
  4. Make project from BuildMake Project [this process may take some time]
Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Shariful Islam Mubin
  • 2,146
  • 14
  • 23
3

Be sure to check for IDE errors by clicking the button at the bottom right of android studio.

enter image description here

In my case, there was a bad plugin, and the IDE Fatal Errors window prompted me to uninstall the plugin. (I wish I'd known about this feature before spending half a day invalidating caches, deleting folders, and reinstalling android studio with no luck.)

Caitlin Morris
  • 889
  • 1
  • 7
  • 6
3

Go TO Left Side Top File Option

Go TO Left Side Top File Option

Then Click To Power Save Mode

enter image description here

Disable Power Save Mode That Fix This Issue

Hanif Shaikh
  • 500
  • 1
  • 10
  • if you can't fix this issue you can check your TargetSDK is 33 that's why you face this issue By You need to change it to Target SDK32 – Hanif Shaikh Aug 29 '22 at 06:43
2

In my case, when I switch keyboard language to English, the auto complete works again.

Hai nguyen thanh
  • 718
  • 7
  • 17
1

If you have a library project included, make sure the library has the dependencies in build.gradle listed using the api configuration, not the implementation configuration. Also make sure that the project that includes the library has all the dependencies listed (using the implementation configuration is fine here).

beetstra
  • 7,942
  • 5
  • 40
  • 44
  • It still doesn't work. I included a custom view in xml file. The attributes(custom or default), doesn't auto complete. Even dimens or string file referencing also doesn't work for only that view. – Paramveer Singh Nov 20 '18 at 06:45
1
'The file size (2561270 bytes) exceeds configured limit (2560000 bytes). Code insight features are not available.' 

Had this issue for days with none of these proposed solutions working before eventually getting this message in yellow under the tabs after adding a line of code. Removing the line of code eliminated the message but not the issue. There appears to be a code size window where you lose insight features but don't get this message, at least for me. Once you go over a certain point the message finally pops up. The suggested solution in a different thread for this issue was to edit 'Help/Edit Custom Properties' to increase the configured limit, but just opening this brought up a dialogue asking if I wanted to create an 'idea.properties' folder so I decided not to risk that approach over eventually cutting the file size.

Androidcoder
  • 4,389
  • 5
  • 35
  • 50
1

if the autocomplete isn't working for you in Android Studio, just press File and uncheck the Power save mode, it should work fine after that. if power save mode is already unchecked then first check then uncheck them.

Arun Aditya
  • 828
  • 8
  • 10
1

If sometimes this problem can occur if you misspelled a file extension or make a file without adding an extension. Check you have added the file extension correctly.

I think that answer may help you.

Kasun Hasanga
  • 1,626
  • 4
  • 15
  • 35
1

I'm using mac and suddenly the code completion (^space) not working. There are no errors. Turned out the android studio's shortcut was conflicted with system's shortcut. I don't know why it suddenly happen because it was fine before, maybe there was an update on my Mac.
See below setting for the conflicting shortcut
enter image description here

Irfandi D. Vendy
  • 894
  • 12
  • 20
1

In my case, C:\Users\UserName\AppData\Local\Google\AndroidStudio2020.3\ just delete caches folder and restart android studio. after deleting this caches folder my problem was solved :)

1

It turned out that I misspelled the word kotlin when renaming the fully-qualified name of one of my modules.

polendina
  • 110
  • 3
  • 10
0

I encounter with this problem while adding a kotlin library into my project on mac. Changing macbook language to english solved this problem. I also had some weird problems with auto-generated databinding codes, those are also solved.

invisbo
  • 3,399
  • 1
  • 16
  • 20
0

Try Invalidate caches/Restart from File in Menu Bar from android studio.

0

Close Android Studio

Go to

C:\Users\YOUR_USERNAME\.android

and rename the following folder to:

build-cache to build-cache_old

then Go to (Android studio lower then version 4)

C:\Users\UserName.AndroidStudio3.x\system

OR (Android studio 4 and Higher) Go to

C:\Users\UserName\AppData\Local\Google\AndroidStudio4.x

or

C:\Users\UserName\AppData\Local\Google\AndroidStudio2021.2

depending on your version and rename these folders:

caches to caches_old

compiler to compiler_old

compile-server to compile-server_old

conversion to conversion_old

external_build_system to external_build_system_old

frameworks to frameworks_old

gradle to gradle_old (if exists)

resource_folder_cache to resource_folder_cache_old (if exists)

Open Android Studio again and the autosuggsion will be fixed.

and You can also check if Power Save Mode is disabled or not from the File menu.

Syed Usama Ahmad
  • 1,307
  • 13
  • 22
  • please explain the logic behind renaming files instead of deleting them straight away. Because either way, android studio will automatically generate these files again. – Saad Mansoor Dec 06 '22 at 09:28
0
  1. Close Android Studio
  2. Open folder "%UserName% \ .AndroidStudio %version%\ system"
  3. Delete folder "caches".

It is works for me.

Style-7
  • 985
  • 12
  • 27
0

First Step : Restart your android studio by this way:

File->Invalidate Caches->Invalidate And Restart

if problem still exists then you should use compileSdk And targetSdk 33

*note : in sdk 33 google want push you to use jetpack compose and auto comp no longer support...

  • "in sdk 33 google want push you to use jetpack compose and auto comp no longer support" this is baseless. what does it have to do with xml autocomplete?! there is a bug in api 33 and Chipmunk version of android studiu; if you update to latest android studio this bug is fixed. – kamyar haqqani Oct 04 '22 at 05:52
  • yes that ' true google fixed it in newest update. – saeed moradi Oct 04 '22 at 07:53
0

I found this issue tracker. I was using Android Studio Chipmunk and I had to update it to Dolphin. https://issuetracker.google.com/issues/241460885. I hope it helps

Jimmy ALejandro
  • 434
  • 5
  • 11
0

Invalidate caches and restart did not work for me. Looks like this is a known issue and the solution is to update to the latest stable Android studio version (Dolphin 2021.3.1). After update everything works fine for me.

Gabriel Trifa
  • 173
  • 11
0

I tried all the hints from this topic and couldn't find solution for that problem, but finally I am leaving here another hint:

Try to disable Lombok plugin and check if it helps - for me it worked. Lombok plays in some way with code suggestions and can break this functionality.

(File -> Settings -> Plugins -> uncheck Lombok)

Especially if you use quite latest Android Studio which is incompatible with Lombok plugin anymore and you installed this plugin by copying it to 'plugins' folder in Android Studio.

Antares
  • 518
  • 6
  • 11
0

Okay, If you still not getting Syntax highlighting or code completion, just press on File -> Repair IDE. That's it.

I had resolved this issue on Android Studio Flamingo | 2022.2.1

Harsh Panchal
  • 146
  • 1
  • 1
  • 6
-1

i have this problem many times until now ,i suggest thees approach :

1-as said check power saveing mode

2-create new project with same application id and package name and copy all source and resource from older project to new one,

FxRi4
  • 1,096
  • 10
  • 15
-1
  1. Close Android Studio.
  2. Go to C:/User/[SystemName] and delete .gradle file.
  3. Open Android Studio and sync gradle file again.
Pang
  • 9,564
  • 146
  • 81
  • 122
Milan Sheth
  • 884
  • 12
  • 11
-1

From menu select: File->Invalidate Catches/Restart...

than in opened dialog select: "Invalidate and Restart" and wait to restart android studio.

A Hashemi
  • 289
  • 2
  • 6