How to re-include an excluded directory in Android Studio? - android-studio

It's explained how to exclude a directory in Android Studio here. It also has a warning about not knowing how to include it back again. Now I need to do so.
Of-course I can create/import the project again. But I guess there's a better way of doing that. Is there? How?

As there is no "Mark directory as" menu in Android Studio, I found out that such settings like including and excluding directories are stored in a ".iml" file. Named like "project-name.iml".
A line like bellow is used to exclude a dir:
<excludeFolder url="file://$MODULE_DIR$/src/main/blah/blah/blah/" />
So, Re-including is done as easily as removing the line.

if you right click an excluded directory in the Project View, you can select from the context menu:
Mark directory as → Cancel exclusion

You must delete .iml file then try to sync and it will work fine

Related

how to include excluded folder in android studio [duplicate]

It's explained how to exclude a directory in Android Studio here. It also has a warning about not knowing how to include it back again. Now I need to do so.
Of-course I can create/import the project again. But I guess there's a better way of doing that. Is there? How?
As there is no "Mark directory as" menu in Android Studio, I found out that such settings like including and excluding directories are stored in a ".iml" file. Named like "project-name.iml".
A line like bellow is used to exclude a dir:
<excludeFolder url="file://$MODULE_DIR$/src/main/blah/blah/blah/" />
So, Re-including is done as easily as removing the line.
if you right click an excluded directory in the Project View, you can select from the context menu:
Mark directory as → Cancel exclusion
You must delete .iml file then try to sync and it will work fine

.gradle\caches\6.1.1\file-changes\last-build.bin (Access is denied)

I've tried to delete .gradle folder or delete last-build.bin file, but it isn't work. Could everyone have the solution to this problem ? thank you...
One simple solution is
I believe that another solution for that could as much be related to hidden folders. If that is the problem:
Check if your User folder is not hidden C:/User..
On the tab menu, select View.
On your far right there will be Options, select.
It will display Folder Options with the following tabs: General, View and Search. Here again, be sure to select View.
Navigate to Hidden files and folders.
And under that folder, just select Show hidden files and folders radio button.
Should that not do the trick, then move on to check if ALL the folders related to that path all the way to Caches are not hidden. The culprit here, should be that the: .gradle\caches is hidden.
Therefore, tap on the folder and unhide it activating the Caches folder(don't open it - just select it) and clicking View once again. Just next to Options on your far right, there should be Unhide selected items on the left. Of course, Unhide them and wait until the attributes are well applied. Now you are good to go, you should not experience that problem any longer.
I think that should do the trick if by any means your folder got hidden. Be sure to do that first, before following any of those technical steps. If your folders are hidden, Android Studio or Intelli j for that matters, cannot access the path in question.
Goto File -> Invalidate caches / Restart
Shutdown Android Studio
Rename/remove .gradle folder in the user home directory
Restart Android Studio (It will download gradle metadata and data)
Gradle build succeed
Rebuild project. Done.
reference

Missing project.gradle in Android View

In Android Studio, project.gradle file is not show when in Android View, but is when in Project view
Android View
Project View
How can I fix this ??
From the Gradle Tool Window in Android Studio (View > Tool Window > Gradle),
Right click on the the project's Gradle config with (root) next to its name.
Click on Ignore Gradle project,
and right click again then click on Unignore Gradle project.
The trigger to this 'buggy' phenomenon actually lies outside your project folder.
Assuming a project name of 'SilverBirch', try this:
(a) Close the project in Android Studio 3.0.1.
(b) Rename your project folder (inside the workspace folder) to 'SilverBitch'
(c) Re-open it via Android Studio (you obviously can't do so using 'recent projects')
(d) You should get a window titled Import Gradle Projects with text that reads: The modules below are not imported from Gradle anymore. Check those to be removed from the ide project too:
(e) Tick the (old) project name and click OK.
(f) At last your 'Android' view shows build.gradle(Project:SilverBitch)
(g) Repeat whole process, renaming back to original.
Alternatively, if you're insane, do this:
Locate the project.dat file AND folder for your project - it will have a path that looks something like this (assuming Windows)
C:\Users\<userid>\.AndroidStudio3.0\system\gradle\Projects\5be1ee38\project.dat
[The system-generated hex-string container name will vary, but the file is always project.dat]
The first line of this file references the 'missing' build.gradle and will clearly identify the owning project.
Delete the file AND its containing folder then re-open the project via Android Studio.
Because googling 'project.dat' yielded nothing, and because I made a rude assumption that this contained only system-generated data, and because I couldn't resist 'seeing what happens' I actually deleted
the entire Projects file [C:\Users\<userid>\.AndroidStudio3.0\system\gradle\Projects]
So far, so good - no serious side-effects yet! Maybe those plugins needed re-specifying anyway? etc.
Close Android Studio -> Remove project .idea folder -> Open Android Studio -> Open your project. This worked for me!
NOTE: when you remove .idea folder you will also lose project related preferences (such as XML code style for project)
Right Click on "Gradle Scripts"
Click Load/Unload modules
Load unloaded project module
Done
In my case, I found that my project.iml located in project/.idea
So I move it to project/
and change one line like following:
<module fileurl="file://$PROJECT_DIR$/My_Project.iml" filepath="$PROJECT_DIR$/My_Project.iml" />
the old one should look like this:
<module fileurl="file://$PROJECT_DIR$/.idea/My_Project.iml" filepath="$PROJECT_DIR$/.idea/My_Project.iml" />
After that, go back to android studio, every thing seems perfect!
This worked for me:
In your root project folder, open the *.iml file, and make sure that the value in module external.linked.project.id=, the *.iml filename, and the project directory name are all the same.
Now my build.gradle (Project: X) shows.
This worked for me.
Simply go to your AndroidStudioProjects Directory.
Search for your Project
Rename it with some other name
Strat your Android Studio, and then Import Project (Gradle, Eclipse ADT, etc.)
mode. let the Gradle Build Finish.
And that's it.

How do I remove directories from Indexing in Android Studio?

I have a large project folder that contains many sub projects. Only 4 are part of the Android project, the rest are C code.
However, it appears that Android Studio is indexing ALL of it, which takes a long time.
How do I exclude these other directories from indexing?
There no way to explicitly do it, and the Module Settings only lists the Android projects so I cannot remove the other folders from there.
Select the directory in the Project explorer.
CtrlShiftA or ShiftCmdA
Search for Excluded and hit enter.
Careful, I haven't been able to find a way to 're-include' folders back yet.
(optional) Switch to project view if you can't see the folders you want to exclude
Right click the folder you want to exclude
In the contextual menu click "Mark directory as" --> "Excluded"
It should look like this:
(optional) If you want to include a folder, click "Mark directory as" --> "Cancel exclusion"
Use the 'idea' plugin to exclude directories. For some reason, it seems the idea configuration is ignored if a subproject is configuring it (and will always exclude the project.buildDir and .gradle folders), but it works if you tell the root project which directories to exclude:
In your root project build.gradle file, do
apply plugin: 'idea'
idea {
module {
excludeDirs.add(file('path/to/subproject'))
excludeDirs.add(file('path/to/othersubproject'))
}
}
After syncing, you'll notice that the root projects .iml file contains corresponding <excludeFolder> tags, and that Android Studio no longer indexes the directories.
In the left side project panel, right click the file you want to exclude from indexing, and then select Mark as Plain Text.
As there is no "Mark directory as" menu in Android Studio, I found out that such settings like including and excluding directories are stored in a ".iml" file. Named like "project-name.iml".
A line like bellow is used to exclude a dir:
<excludeFolder url="file://$MODULE_DIR$/src/main/x/" />
So, Re-including is done as easily as removing the line.

Android Studio project folders not showing

I am unable to see the folders that are physically existing, this is the case.
But in actual fact I have other folders as welll
So what can I do?
Above your the file directory view in Android Studio is a drop down which currently is most likely set to Android. Change it to Project and you should be able to see all your files.
I tried the all the approaches mentioned above but can't fix rather than fix it by a hardcore approach -
Step 1. Close your Android studio.
Step 2. Delete .gradle and .idea folder from your project directory.
Step 3. Open your project and you will see the files again.
go to View menu then click tool window then after click on project
view->toolwindow->project
it worked for me
for me doing the following works:
from menu go to: View--->tool windows ---> Project
then click the little gears icon (settings) you will see an option to change the empty middle packages. it looks like this:
disable "Hide Empty Middle Packages" under the Project View settings dropdown and then it should make everything show up.
If anyone ever does what I did maybe this will help:
Android Studio does not like it when module names begin with a number. I was learning from some tutorials and named the first module "1-name" and the next one "2-name". Setup was fine and it ran, but only the "Gradle" Scripts entry would show in the navigation window in "Android" mode.

Resources