New Directory vs New Folder in Android Studio - android-studio

What is the difference between creating a new directory and creating a new folder in Android Studio?
Here is an image of the menu choices:

Short answer
Use folder when adding a folder to an Android Studio project. This is what Android Studio calls them. Directory is what IntelliJ calls a folder. Android Studio is built on top IntelliJ so there is some naming confusion.
Long answer
Although there is a technical difference between a folder and a directory (see here and here), they are often (correctly or incorrectly) used interchangeably. This can be seen even in the titles of these two SO questions:
Setting a custom assets directory for unit testing in Android Studio
Adding an assets folder in Android Studio
This can be confusing to new users of Android Studio when they see both choices in the menu structure. Further confusion results when users add a new directory and then it doesn't show up in the Android folder view. See these questions for example:
Android Studio: Newly Created Directory Not Appearing In Folders View
New created "values" folder is not visible in Android Studio
The folders actually do show up if you select the Project or Packages view from the menu:
However if you want an Android folder to show up automatically in the Android view you need to right click and use New > Folder > Assets folder (if you are adding an assets folder). You could then add a subfolder like "fonts" to this by choosing the New > Directory option.
Android Studio is built on top of IntelliJ IDEA. IntelliJ itself has a menu option to add a directory (as you can see here). But Android stores files in what it calls folders. So when these two platforms are put together in Android Studio, there gets to be some naming confusion. (This is my interpretation, but perhaps they really are trying to differentiate the subtle differences between directory and folder.)
You can see from your menu image that there is also an "Android resource directory" option. (You got that by right clicking on the res directory/folder rather than a subdirectory.) You would use this to add resource folders such as raw, menu, values, etc.

Related

In Android Studio, how do I create a folder for project documentation?

In Eclipse, I had some folders in the project root that were not code - containing text files with notes about the project, Photoshop files for artwork and so on. Having migrated to Android Studio, these extra folders in the project root are not visible in the Project navigation pane - I only see the app folder and Gradle Scripts.
Is there some way to create a non-code folder that is visible in the Project pane but that is outside the app module?
I thought "Create New Module" in the Project Structure dialogue might do it, but it only offers me templates for modules that contain Android code.
--- EDIT ---
Thanks to #SvdTweel's answer I've stumbled across something that seems to do what I want:
switch to the Project view
create the documentation folder in the project root
right-click it and select Mark Directory as>Resources Root
switch back to the Android view and you see a new folder named "resources"
Will this have any adverse effects? Is this folder still ignored when building the app module?
In the Project Structure you can switch from Android to Project.
The default Android view structures and minimalizes the directories and files so that you as a developer can easier navigate through your project.
The Project view shows everything just as you would see when you browse it with your file explorer on your OS.
I think that is what you search for to create files and directories in the root of the project.
You can put the doc files in the test/resources folder. This is clumsy, but it makes them visible in the Android view while keeping them out of the build.
Bonus: code completion when editing Markdown code samples using the JetBrains Markdown plugin.

How to add folder in android studio

I tried to add a new folder in android studio, but It hasn't created.
I click right mouse button on res folder -> new -> Android Resource directory (or just a directory) ->
write a name and click enter, but there is no new folder in android studio explorer. When I check res folder in windows explorer I found, that these folders are created, but I can't see them In android studio.
Honestly, I tried to create layout-large firstly, but then I discovered, that there is no way to see created folders in android studio.
What can it be? How can I fix this problem?
Thanks
if you need to see the created folders switch your project view from Android view to Project from the dropdown menu in order to see them. Android view allows you to see the default Android project resource folders only, any additional folders will not be recognized by the Android view.

How can I change title of android studio that is visible when switching apps on macos from folder name to project name?

I moved my project files to project subfolder so I can put other stuff on upper level like some artworks etc to commit to git too, without having it messed with project files.
Now when I switch between various open android studio projects windows, I see there just title of that parent folder, that is named "project", but I would like to see there my project name, not folder name. Is there some android studio setting to change this behaviour ?
In your settings.gradle add line rootProject.name = "some-desired-name" and this will be visible when switching apps on macOS, I believe it's called mission control, otherwise Android Studio pick folder name as project name and that was my issue.
Background: I used this before, but later commented it out, because I didn't see why it would be useful for me, now I see.

Invisible folders in Android Studio Project view

I have recently switched to Android Studio and try to migrate an ADT project.
In the app/src/main/res/ directory I have the values, values-v11 and values-v14 folder. But in the Studio's Project view only the "values" folder is displayed. Why? How to resolve this?
Android Studio puts them by default into one view, physically there are still in different folders. If you want to change this, just change the project perspective in the project view on the left side.

What is the extension of a Android Studio project file?

What is the Android Studio equivalent of Solution file in (.sln) file in Visual Studio ? I created a project in Android studio and closed it. Now I am not sure which file should I open to reload it into Android studio.
Use the import project function on the build.gradle file in your project root (not the folder itself!) to open the project again in Android Studio.
I think ".iml" is the extension for Android studio projects.
".project" is for Eclipse projects
Opening a saved project on another drive
There is no such single project file that needs to be opened but rather the directory where the whole project is stored.
Find the directory where you have saved your project
In Android Studio -> Files -> Open->(click on the directory name where your files/project is stored)
Except using android studio unique method(import), you can also double click .iml file to open corresponding project.
If you using Windows operating system, you could right click .iml file in file explorer, and select studio64.exe to open it, then android studio start the project!
At least in the version I have, like intellij the "android studio project files" are stored in a folder called '.idea' in the root of your workspace (though you can explicitly create one that looks up the tree and have it not be in the root).
If you add this folder to source control, do not add the file "workspace.xml" as that is the state of the window positions on your machine and should remain local, checking it in will cause lots of confusion.
If this directory is present, android studio will give the containing folder an android studio icon in it's open file browser window in the windows version. You can click on the directory with this icon in intellij (android studio) and open the project.
In Windows, Click at projectname.iml under project directory root. If window is not does not have the .iml file association with Android Studio, you need to add it.
When you select File->Open in Android Studio and navigate through folders, you will notice that folders which consist valid Android projects would have the Android Studio icon, clearly indicating that this is all you have to select.
It is unusual approach in terms of normal behavior of programs under Windows, because since very first versions of Windows it's become accustom to be able to open a program by double-clicking on the file associated with such program, but I guess developers of Android Studio decided not to do that.
It is possible that ".iml" file could be associated with Android Studio but it doesn't happen by default and it's not associated on my computer neither.
I ran into this problem, after upgrading Android Studio to 3.0 on Mac. The previous projects I had created were not displayed, in the splash screen, during startup of 3.0, so what I did was:
1. Pick the option to Open a project
2. Navigate to the location where the project was previously saved (~/AndroidStudioProjects/projectFolder)
3. Select the folder (don't double-click it)
4. Click button: Open
5. Result: this opened the project.
So there is no need to select any particular file. I suspect the filer of this problem was double-clicking the project folder and then wondering what to select next, which is what I did, initially. But it turns out that the Open button is required, in order to open the project. Otherwise, Android Studio anticipates that your intention is to open the folder.
.iml file can be used to open the project directly into Android Studio (I am referring to Android Studio 3). Just goto your project folder and then double click on yourProject.iml file.
I know its late but better late then never :-)
Visual Studio uses one solution file. Android Studio does this different. It uses a directory for this purpose, namely the directory .idea in your project. In this directory several files make up how your IDE is configured for that project. The same as in Visual Studio. Those files can be edited and changed, but you will have to know what is what in those files.
I think the answer is .duh
Please see screenshot:

Resources