In android studio,cannot load 2 facets-unknown facet type:android and android-gradle - android-studio

When I open android studio I am getting an error- "Error loading project: Cannot load 2 facets. When I clicked to see the error the following appeared
"2 facets cannot be loaded. You can mark them them as ignored to suppress this error notification.
Unknown facet type:'android', Unknown facet type:'android-gradle'
I tried to add facets ( In Project Structure > Project settings > Modules > clicked project name, then clicked Android as well as Android-Gradle) But both showed as "cannot load facet, unknown facet type." Under Project settings > Facets > both Android and Android-Gradle are displayed as 'Invalid facets'.
My project was running smoothly. This problem occured when I force-closed my laptop before exiting android studio as everything got stuck. After that whenever I open the android studio this problem occurs. I am not able to run my project. Can anyone please help me to solve this?

Just enable Android Support plugin.
Click Ctrl+Alt+S in Windows or Meta+Comma in Mac.
In top search bar type "plugin".
On right side it will show a list of plugins, find Android Support plugin, check it and click OK at the bottom of screen.
This is how it looks:

In Android Studio go to
File -> Settings - > Plugins -> Enable "Android Support" Plugin.

File, Then Settings->Plugin->Enable/Renable Plugin --> Apply --> Restart

This problem occured when i'd updated Android Studio.
In case nothing from other answers works, you don't have another option, except removing broken settings and making clean setup.
So what i am suggesting:
Use Settings Repository Feature to store personal IDE settings
close studio
remove .AndroidStudioX folder from user folder
re-launch studio, do not copy settings from previous version (because settings probably broken and auto-import couldn't import it well)
import personal settings from Settings Repository

For me I went to Settings -> Plugins and de-selected Gradle then immediately re-selected it. Android Studio then asked if I wanted to enable Groovy so I said yes and let it restart and now everything is happy again! (it was checked, but clearly somewhere deep down not truly enabled, so toggling the check-box sorted it)
Not sure if my cause was installing Flutter, but I did have to disable the Flutter plugin before I could build again.

I had the same problem with an ever-increasing number of facets - first 2, then 4, then 5 - and none of the above solutions worked. My solution (Android Studio 3.3, OS X) was to delete ~/Library/Preferences/AndroidStudio3.3/disabled_plugins.txt, which contained org.jetbrains.android and org.jetbrains.maven
I imagine if you have deliberately disabled plugins then you'll have to disable them again manually, but I was able to load all facets again.

Go To ->File->Settings->Plugins->disable/enable Android Support Plugins->Press Ok
Just re-enable Android Support plugin. Then it will ask to restart.
Restart them thats it

I faced this issue in Android Studio 3.2.1 I had to re-import my project after that it works.

I was facing this problem, I tried everything but nothing worked but then I remembered that I updated Android Studio just few hours back and then I enabled the plugins in the Android Studio and restarted it and it worked.
File -> Settings -> Plugin and then just press ok. It will ask to restart the android studio and please restart it.

For me I had to uncheck the plugin Android APK Support. I clicked Apply and then Ok to close the window. Android Studio prompted me to restart the program, and the program restarted. I checked the Android APK Support plugin again and restarted the program. And then I selected File -> Sync Project with Gradle Files
Then it worked just fine.

Related

"Generate Signed APK" option is not display in android studio Build menu

"Generate Signed APK" option is not display in android studio Build menu,
What is the problem or something I missed to install?? Thanks
When I click "Build APK(s)" , the android studio is no response
For me, clicking File > Sync Project with Gradle File System solved it for me.
Firstly check with clean > rebuild project and see that 'app' is not having "red X" icon.
Check your gradle that you had not configured it with release config yet.
There must be a signing config in gradle file
Follow Below Steps for Nice and Easy Way:-
Go to Tools->Flutter->Open for editing in android studio.
open for editing in android studio
Choose separate window. This will open the android part of your project in separate window.
Wait to Gradle to finish it's build.
Go to Build-> Generate signed bundle/apk.
Follow this video for further process.
Thank me later..!
in my case, one of my harddisks hard stopped working (in which I had my first project).
File > Settings > Appearance & Behaviour > Build, Execution, Deployment > Build Tools > Gradle menu, changing the Gradle user home to another folder solved the issue. the original value of it consisted path to my first project which wasn't existing anymore.
I had the same issue not having the "generate signed bundle/apk" enabled in Android Studio interface and this thread helped to deduce what was my issue... I'm new to android development so I didn't know what to do at all but checking the build.gradle file I realized that there were issues with the synchronization of gradle, so I found this video, downloaded the latest version of Grandle, then went to File > Sync with Fyle System, and after the sync was completed the button appeared.... so seems like this has a direct relation to the right synchronization of gradle.

Could not find a JavaToKotlinConversionProvider

I'm not able to create a new project in the android studio. I am getting a warning message
java.lang.RuntimeException: Could not find a
JavaToKotlinConversionProvider, even though one should be bundled with
Studio at
com.android.tools.idea.npw.model.JavaToKotlinHandler.getJavaToKotlinConversionProvider(JavaToKotlinHandler.java:56)
at
com.android.tools.idea.npw.template.TemplateValueInjector.addKotlinVersion(TemplateValueInjector.java:410)
Go to Preferences -> Plugins -> Kotlin and update the Kotlin plugin to the last version even though you don't write your code in Kotlin.
I have the same error, I've juste disabled the kotlin plugin and after restarting the IDE, just re-enable it. After that final restart, every thing works fine.
Go to file and the plugin in android studio and update your Kotlin plugin...
I opened an old project (by old I mean another project) and did everything Android Studio said to give me a successful build (I faced some errors when I tried to build the project that I could build couple weeks ago and actually I fixed them, updating gradle and stuff like that, not code issues of course).
After that I could create new project same as before.
Update seems like in order to keep Android Studio happy we have to keep Kotlin plugin enabled, interesting.
I solved this problem by doing this:
File->Settings->Plugins
Click the Installed tab at the top.
Search "kotlin" and click the result that shows up.
Click Enable at the top right
settings>plugins>check Kotlin >Apply then Ok solved it for me.
It occurred due to migration from Android Studio 3.2 to 3.3
Goto File-->Invalidate Caches/Restart
This will solve the problem.

Annoying "Create Desktop Entry" popup in Android Studio on Ubuntu 16.04

Recenty I installed Android Studio on my laptop running Ubuntu 16.04.
When I created a new project and used Android Studio, this annoying popup kept showing: (Because my low reputation, I cannot post images, please click the link below)
https://i.stack.imgur.com/zNMbk.png
I tried to check the checkbox but it still display everytime I click on anywhere in Android Studio.
Help me, thanks in advance.
Try to use this for creating a desktop entry: desktop-file-install THE_DESKTOP_FILENAME_HERE.desktop
It might be the solution (if error it's because it localized the fileB, if ok it will copy to the correct localization /usr/share/applications) Restart then
After trying many times, I decided to reinstall Android Studio and the error disappeared! I don't know the reason clearly but maybe using Create Desktop Entry in Android Studio and creating a .desktop file manually (after installing Android Studio, I wanted to add Android Studio icon to launcher) caused conflicts.
goto settings in android studio
keymap-> main menu-> tools-> create desk entry
right-click on "create desktop entry"
you will get an option to turn off it.

Auto complete not working in android studio

I am a starter in android development and I started off with eclipse.. But it started giving lot of problems. So I switched to android studio. Got it set up successfully and for couple of weeks it was ok. Now, for some reason, the auto complete feature is not working. It is not giving any choices while typing, so I tried ctrl-enter. It says no suggestions. I browsed through similar queries and tried the following.
Disabling Power Save in File menu.
Checking basic complete and smart type completion in IDE settings (editor)
Invalidate caches and restart.
But non of these seems to work.
Try with CTRL + space and you will get the drop down .
I had the same issue and solved it.
Go File> Invalidate Caches / Restart... > Click at Invalidate and Restart
Then you can also check if Power Save Mode on File menu is disabled.
Source: Android Studio - Auto complete and other features not working
These following steps are working for me:
Close android studio
Go to path/.AndroidStudio3.5/system/ delete caches folder
Start Android Studio
You should Try this way File->Invalidate Caches/Restart or you can find solution by using below link
https://stackoverflow.com/a/58214439/11404883
In my case on Android Studio Artic Fox edition there were strange problems with autocompletion and suggestions because of old version of Gradle plugin. I have updated to
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21'
and it worked as expected. Hope it will be helpful for new visitors like in my case it would.
In Ubuntu 21 I had tried
$ rm -rf ~/.cache/Google/AndroidStudio2020.3/caches/
I followed all the steps from various answers and sources, still didn't get it to work. Code completion and Syntax Highlighting was not working.
I restarted using Invalidate Caches and did Gradle Sync atleast 10 times.
It was working in main flavor, but not in other flavors! In this project we have multiple flavors.
So finally the solution was found using
Android Studio product flavors only recognized one out of two flavours
Just selecting the correct Build Variant solved my issue.
Delete everything inside caches folder
C:\Users\<user_name>\AppData\Local\Google\AndroidStudio<version_x>\caches
and restart android studio

Android Studio - automatic project load

I cannot find a way to prevent Android Studio from automatically loading the last project in use. I want it open me the beggining window with the list of projects available and not loading the last used automatically.
The location of Reopen last project on startup was moved to Settings => Appearance & Behavior => System Settings with new Android Studio, just uncheck it!
In Appearance & Behavior -> System Setting , also you can change some other setting about open or save projects
Android Studio 2.1.1 MacOS X
UPDATE
This screen can accessed in Android Studio 3.1.3 on MacOS High Sierra by selecting the Android Studio -> Preferences menu
Android Studio or Intellij IDEA:
From the menu go to :
File > Settings >Appearence & Behavior > System Settings.
disable the option:
Reopen last project on startup
Open Settings, go to General and remove check from Reopen last project on startup
If the project that is being reopened is causing android studio to stop responding you may not be able to get to the dialog. I got round this by deleting
~/Library/Preferences/AndroidStudio3.3/options/recentProjects.xml
This allowed me to temporarily start android studio without reopening the offending project, and then permanently disable the reopening feature using the dialog others have mentioned
I ran into this problem on MacOS when I added Android Studio Canary and Intellij. I'm not sure which caused the issue.
Anyway, here's the steps that I used to fix it:
Open Android Studio to see what project it opens; write down that project.
It will freeze, so you need to force quit it.
Erase the nodes where that project name exists. For me it was the last <entry> element and the <option> element in the recentProjects.xml file (location below). Make sure you delete the complete element!
Restart and it should work. Otherwise, repeat for the new recently opened project that is freezing Android Studio.
Where is the file?
~Library/Application Support/Google/AndroidStudio4.1/options
It took me digging up the location of Intellij files then back tracking it to Google then Android Studio to find where the file exists. I hope I save someone the time I wasted on this. :D
Extra note:
The <entry> node is in here:
<application>
<component name="RecentProjectsManager">
<option name="additionalInfo">
<map>

Resources