Android Studio file type extension definitions - android-studio

I created a new file (with .frag extension) within Android Studio, and a window "Register New File Type Association" popped up. I wasn't paying attention and I selected "Open matching files in associated application" which now makes it so any time I try to open a *.frag file it opens in Gedit (which I had open at the time of the file creation). I checked file types in Settings but I didn't see an option to change the association definition. I want my *.frag files to open in Android Studio.

register-new-file-type-association-dialog
I just made the same mistake.
Go to Setting
write 'file types' on the search box
select the 'File types' under 'Editor'
find the one you assigned and delete it.

I ended up setting Android Studio back to default settings using this link: Reset Android Studio settings to default setting on linux

Related

Android Studio 2.2.3: Favorites, bookmarks and opened folders keep disappearing, project and .idea-folder are always rebuilt

I'm trying to use favorites and bookmarks with Android Studio 2.2.3 on Windows 7 in order to navigate through our code base.
I have openend one project, where the saving of favourites and bookmarks works fine. BUT when I open another project, while my first project is open as well and then close one of the 2 projects, the closed project loses all the favorites, bookmarks and which folders and tabs I had opened.
Also AS keeps asking me to add the VCS root everytime I start it.
Although I've searched I could not find any sources describing my problem.
I've copied all my projects into a new folder and gave myself all permissions to this folder, which did not fix my problem, so I think permissions are not the problem.
My assumption was, that Android Studio might have trouble if you use multiple instances.
So I went and tried to set it to only use one window:
But this setting keeps getting ignored and AS opens a new window for every project.
I reset all the settings for Android Studio by removing the folder C:\<username>\.AndroidStudio2.2.
Then I re-started Android Studio and didnt import any new settings.
With this configuration my problem still occurred.
In order to reproduce the 'bug' do this:
Open a project by File -> Open (NOT File -> Open recent!)
Add bookmarks
Open another project (while the first project is still open!) by File -> Open
Add bookmarks there as well
Close project 1 and re-open project 1 by File -> Open
All tabs / bookmarks / favorites should be gone at this point.
Vadim Kotov has confirmed that the problem happens with his Android Studio as well, so I suspect a bug in AS.
How can I fix the disappearing favorites, bookmarks, opened folders and tabs?
This problem seems to be a rather old bug in Android Studio:
https://code.google.com/p/android/issues/detail?id=172347
The bug is fixed in the Android Studio 2.3 BETA-release:
https://code.google.com/p/android/issues/detail?id=232670&thanks=232670&ts=1485023505
Basically Android Studio seems to overwrite the workspace.xml in the .idea-folder for a project with a default - workspace.xml everytime I use the Open - menu.
AS probably re-creates the whole .idea-folder and rebuilds the project, everytime I use the File -> Open-dialog.
Workaround:
Since I cant switch to another version of Android Studio due to company rules, I use the following workaround:
When you want to open a project for the first time, you have to use File -> Open
After that, ONLY use File -> Open recent in order to get into one of your projects
This will save the opened tabs, bookmarks, favorites and will open only one instance of AS in the forground instead of the background.
WARNING!
If you later click on File -> Open either because the recent-menu is filled too much, or you do it by accident, you still probably will lose your bookmarks, favorites etc...

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:

Importing an existing source file in Visual Studio 2012

I want to add the source-code of a tutorial into an existing project, and I want the file to be copied to the project folder from the temporary file on the desktop I downloaded it to. Context clicking on the "Source Files" Folder in the Solution Explorer leads me the Add->Existing Item... menu, and I can then add the source file. However, it is NOT copied into the project folder, but stays in its original location. The project just knows about it, displays it in the Solution Explorer, and considers it part of the project.
This help page on MSDN tells me that in Visual Studio 2010, default behaviour used to consist in copying the file into the project folder, and that one could choose to Add a link instead of physically importing the file into the project directory by choosing "Add Link". However, now I always only get a link, and real physical import into the project folder seems impossible.
I could go through the File Explorer to physically import, but the Solution Explorer doesn't update the new files on the fly, and I would like to do this from within VS.
Is there a way? Is this a bug in VS 2012?
Copy in the files using Explorer, then in the solution explorer tick the Show All files option in the button bar of the solution explorer (you might need to select a Project first).
You can now right-click any files not part of the projects and choose Include in Project.
Or use the Add Existing File option.
The reason files are not added automatically to your solution when pasted into the folder using Explorer is because you might not want to have them added.
A neat little trick is to use the "Open In explorer" option:
(though it might be added by the Productivity Power Tools).
Plus, you can Drag&Drop files directly from explorer to the Visual Studio (when they're both running in the same elevation level if you have User Account Control enabled). To fix the UAC issues, you can either run Explorer as administrator too or install the VSCommands extension.
And you can Copy&Paste a file or set of files into the solution explorer by right-clicking a project or project folder and picking Paste on the context menu.

Project that I just opened "could not be opened"?

I have a VS2012 C++ project. I can open the project by clicking on the .sln file, but when I open VS2012 and try to open the project from the Start Page, I get this message:
"TestApp2" could not be opened.
Do you want to remove the reference(s) to it from the Recent list(s)?
I don't get this message for all projects, just this one.
I'm trying to run it from the Start Page because I want to run the code as an Administrator. I can right-click the VS2012 icon in the Start Menu and click "Run as Administrator", but right-clicking the .sln doesn't provide this option.
Is there something I can do to fix the project so it can be opened from the Start Page? Or is there another way to open the project as an Administrator?
The link that is stored in the memory for Visual Studio, is now different. This is the only way that could happen. So, remove it from the pinned recent solutions, open it manually, and then it will have the correct linkage in the Visual Studio menu.
Sorry, didn't see prior post on same solution. :)

Turn off visiting behaviour when navigating to file in Visual Studio 2012

When I go to another file, using F12 on a type name in the code, it will open the file in a read-tab to the right. If I navigate further the new file will replace the previous one.
In Visual Studio 2010 it would open a new tab for each file I go to. I've tried to get used to the new behaviour, but I can't stand it.
How do I turn this feature off?
Visual Studio 2012 has a new Tabs and Windows settings page under Tools > Options > Environment that controls this kind of behavior:
You probably want to disable Allow new files to be opened in the preview tab in the Preview Tab section.

Resources