Another solution that worked for me with Android Studio 3.1.2:
delete these from build.gradle
if you have them:
'com.android.support:appcompat-v7:27.1.1'
'com.android.support:design:27.1.1'
then sync, then undo delete, then sync again.
I encountered this after updating to Android Studio 3.1.
None of the other answers listed here worked for me, however when I switched my appcompat support lib version to the latest 28.0.0-alpha1
then back to 27.1.0
that it was on before, it worked.
Seems the new version of Android Studio lost connection to where the library was synced to and just needed to have it reset.
No need to change anything.
Just press small button on top "Sync Project with Gradle Files"
EDIT: As @Alexey noted, bug still appears in Android Studio v3.1.4
This worked for me:
That's because of feature called "build cache" that is enabled by default in build Android Plugin since 2.3.0. It creates files in build cache outside of project folder (in my case -- in \Users\%username%\.android\build-cache) Theese files are intended to be common between your projects.
And then Android Studio is unable to navigate in theese files. That's all.
If you want to disable Build Cache, add android.enableBuildCache=false
to gradle.properties
file. Then restart Android Studio.
more info here: https://developer.android.com/studio/build/build-cache.html#disable_build_cache
I have had the same problem. The only solution that worked for me was to manually delete the support libraries in file system and sync the project to let Android Studio download them again.
Steps:
.idea\libraries
Gradle__com_android_support_****.xml
filesFile > Sync with File System
File > Sync Project with Gradle Files
Build Project
And now your error should be gone!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With