(Shorter solutions to the problem are shown above and have many thumbs up votes. If they don't work for you, several people have thanked me for this, so give it a try.)
I was using Android Studio 3.0.1
and Gradle 4.1
when I got the "Facets" errors. I fixed it by doing what follows.
Stop AS. If AS is hung, force it to stop using Task Manager.
Restart AS. if you have errors and NO WAY TO GET TO FILE>SETTINGS…, you likely are where I was. Read on.
If you have a popup about facets
that is similar to this...
... look at Gradle console. If you get the message Problems found loading plugins
, followed by a list of errors that say “required plugin
Android Support is disabled " , followed by a message that has a link saying " ...
( show balloon)`, click that link.
The link will have an option to Choose to
enable Android Support `. Do so.
Restart AS.
If you can get to File > Settings
and have no errors, great. I guess you're finished.
But I faced a new error, so you may too:
If you get this error...
Info:Gradle tasks [clean, :app:generateDebugSources,
:app:generateDebugAndroidTestSources,:app:mockableAndroidJar]
Error:Failed to complete Gradle execution.
Cause: **Write access is allowed from event dispatch thread only**
... go to File -> Project Structure -> SDK Location
.
Check the box Use embedded JDK
.
Set jdk location
to C:\Program Files\Android\Android Studio\jre
.
(My path was set to C:\Program Files\Android\Android Studio
1\jre
. The 1 is a little disconcerting, but ok so far.)
Hit OK
and exit Settings
.
Choose Run
or Debug
(or Run …
or Debug …
).
(If you still have problems, check out the other Answers above and below.) This is as good as I can do. Sorry if it didn't help.
This seems to combine two or three threads about two or three problems:
Facet errors (I ignored the popup.)
Plugin errors (but no access to File Settings)
Write access only from dispatch thread (for which the fix seems unrelated).