Android studio, how to delete folder with references? - android

i would like to delete one folder (unused library) from my project in Android Studio. But i cannot to do that by delete key on keyboard or any other way.
I tried to found delete under refactor->safe delete, but this option is disabled.
If i removed folder manually from folder, Android studio created a folder again and putted in one .iml file, so i cannot delete folder again.
Thanks for any help.

Remove it from settings.gradle
Build --> Clean (the blue rectangle should disappear)
Right click on module -->Delete

To remove a module, you first have to delete it from .idea/modules.xml.
Once you do that and save the file, you'll be able to delete the folder, which will no longer be marked with the module's blue rectangle.
Don't forget to remove the module from settings.gradle.
I found this aswer at delete project in android Studio 0.3.4

The problem is occurring because of workspace.xml and modules.xml inside .idea directory of your project.
You cant not delete any module if there is blue rectangle over it, Follow the steps to delete your module from project :
Go to File> Project Structure , select the module you want to delete and press the red minus sign button to remove.
Note : Also remove if any reference in build.gradle file of your main module.
Clean your project using Build > Clean Project
Close your Android Studio now
Go to the project directory and delete the your_project.iml file and content of .idea folder from project root directory, also delete the module directory which you want to remove.
Open Android Studio again and let it sync the project with gradle
If module appears again there will not be any blue rectangle mark on it so you can delete by right click > delete and clean your project.
Sync your project again with gradle, if it appears again check your event log if somewhere something from library is used, if it is remove them all.Check your File > Project Structure as well if there are any error referring to your module library on bottom. If it is using the red bulb button remove it.
After remove all things Clean Your project and sync again.
Let me know in comments if any problem occurs.

Related

Why Project's build.gradle is not showing?

Why is Project's build.gradle not showing up in Android mode?
Just like the picture below, the .gradle file in the project root directory can also be displayed in Android mode.
enter image description here
You need to change it at here. You choose to display the project instead the Android.
You changed the display mode. Notice that the first image, you configured to "Project Mode" and the second one is in "Android Mode". It's on the upper-left corner of the "project" tree view.
Your using project structure better to use android structure view
secound thing is if you want to use project structure then project->build.gradle is your project level gradle file for Ex. AndroidWeather/build.gradle
This can happen when the caches get messed up. Try this:
Close the project in Android Studio
Delete the .idea folder in the project folder:
In Android Studio, File / New / Import Project... and select the folder of the project
Note, to delete the folder:
cd /path/to/project
rm -rf .idea
Now you should see the project-level build.gradle in the Android scope.

Project already contains module with this name -- Android Studio

I had successfully imported a Module in my Application project in Android Studio.
Then I deleted or removed the module by following the below link:
How to delete a module in Android Studio
I also removed the project module from the dependencies of my build.gradle(app) file.
Now, When I need to again include the same module project in my Andorid Application, it doesn't allows me, and gives the Project already contains module with the same name error.
I had check in my Project, Package, Android Structure but the project module which i need to Import and add as a Module Project is not there but still it say it already exist.
Can anyone help me to overcome this issue.??
If somebody faces this issue, except removing the Folder containing the old module also remove from the settings.gradle file the line corresponding to the old module: include ':youroldmodule'. If you dont remove that line manually, 2 modules with the same name will appear when trying to add module dependency.
Switch to the Project View. Then open .idea/modules.xml. Find and delete the line that corresponds to the module. Then Invalidate Caches and Restart. That's it.
I solved the problem through this way:
Open Module Settings(Mac: command + down; Windows: F4) and delete the module.
Delete the module folder on the disk. You will find it at ~/AndroidStdioProjects/YourApplicationName/ModuleName.
Import the Module.
I have encountered this.
And I deleted the folder which below my project with the module name I set before, then I can import a module with same name again.
Hope this helps you.
The project view on the left hand side, doesn't show 'everything' your project contains. You can switch the view from the drop-down menu, which is defaulted to 'Android' and change it to 'Project Files', which will probably show you where the problematic reference to the Module remains.
Alternatively, just check on disk where your project is located. I found references in the main project folder.
You can't import a module if you've put the code for the module in the place it will end up being copied to. I had the module source code placed in the project root folder and it failed to import with the above message. If you move the code away somewhere, on import Android Studio will copy the code in.
If you still see the error after removing the code from settings.gradle and the app gradle file, check the following file and remove any entries with the module name you are trying to remove.
./.idea/modules.xml
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
Remove compile project(':module_name') from build.gradle under app folder
then remove module folder under your Project Folder
then remove your module name entry from settings.gradle
This worked for me:
In app/build.gradle, remove this line from dependencies {:
implementation project(':library')
In settings.gradle, change
include ':app', ':library'
to
include ':app'
Then you can import the library. Be sure to put the lines back into the gradle files you took out above.
Those who are still seeing this issue and have already removed the module from settings.gradle file but still sees that Module already present while importing it again, This is what I did:
1.) Switch to Project mode in Android studio for your project
2.) Once switching it to Android mode, delete that module manually by clicking right click on it.
And Hope it works for you now.
I am Not Sure but I hope it's Help you.
Step 1:
Pressed Alt + 1 for get Focus of your App.
Step 2:
Now Pressed F4 for open Module structure of Project
Step 3
Now Select Dependencies and Remove All Extra dependencies of your project.
than Pressed OK.
and Resync gradle.
I hope you are clear with my solution.
Best Luck
I had this problem when I was trying to add junit 4.12 to my project.First of all I delete old junit codes in dependencies of my build.gradle(app) file manually.Next I deleted the old junit.jar from my library with deleting libs folder and then create new libs folder directory in my app for add library.and for the end.......I find the old junit FILE near the end of project view after gradle folder....you can see in this image......and I deleted it.now I can add new module very easy and without same name error.sorry for bad english!!
look this image for last order
I solved this by removing the existing module from the project structure, then renaming the folder. It finally worked when I removed the folder, ran a sync, then re-added the folder and attempted to import.
In one condition if you have copy a folder like this
rootProject/module1
if you import module android studio will find if you have same name folder.
if you have it is not import android studio will tell you you have contains this module ,you just add this in setting.gradle
like
include ':modlue1'
If shows this error after deleting the module from project structure then, select Project view of our project in android studio and then explore and the there will be the folder of module that we imported, right click on that and Delete it and rebuild the app.
If any of the above answers worked for you and you are sure that your branch is clean then close your Android Studio, browse to the root of your project and delete .idea folder. Then re-launch Android studio and run your project.
I had same issue, initially created a module, then removed it from settings.gradle and finally the fix was to ACTUALLY remove ALL folders related to that module, those won't be visible in the ANDROID view, hence change to project view and remove all related or browse using an external tool and remove all folders
For me, there was still a reference to the old module in my project's /.idea/gradle.xml file:
<option value="$PROJECT_DIR$/mymodule" />
I just deleted that line then re-synced with gradle and the error went away.

Deleting library file from subversion in Android Studio

I want to delete a library file from subversion.
The steps I follow are
1. Delete from my libs folder
2. Delete dependencies from property file
3. Then Synchronize to commit the change
The issue happening is I cant see the deleted file to commit while synchronizing. What am I missing? I need to delete this library file from Subversion. I am doing this through Android Studio
Follow below steps :-
1. Select parent folder and right click.
2. And click on commit button.

How to remove a dependency from my Android project in Eclipse

When I highlight my project, go to properties, select java build path and then try to remove an Android Dependency from my list of Android dependencies the remove button is grey'd out. How can I remove that specific dependency?
JFTR:
I have had similar problem after a messed merge of two projects branches on Eclipse. I could revert the merge as I did not commited yet, but Eclipse project files that I do not store in my repository was messed.
The solution for me was to:
Delete the error message from "Problems" view.
Clean the project (Project / Clean...)
Solved!
Delete the dependency from the libs folder.
Well, the above solutions didn't work for me so I just enter the project.properties file and remove the dependency (which is written there as a reference).
These are the steps on Ubuntu:
Using console on project root folder type sudo vi project.properties
Go to the line that you want to remove and delete it (you can type double d to remove a line --> dd)
Close and save the file (press ESC and then wq)
Clean the project and rebuild.
Note: Before you change project.properties manually you are strongly advised to backup your project since this operation is unsafe!!!
Sorry for the elaboration for those who speak fluent Linux.
2 types of dependencies I can found so far under Android Dependencies:
Build path to your workspace libs folder
Build path to some other project which install by Android tools and
create as another project under Eclipse, e.g. GridLayout for
android(android-support-v7-gridlayout.jar)
To remove the first one, it is easy. Just delete the jars under libs folder.
To remove the second one, it is also easy. Just go to the project's Build Path, select Android, remove the reference item under Library panel

How to fully remove an external library in a project?

I would like to fully remove all the links to an external library in my project. How can I do that ?
What I did:
Right click on project folder => Properties => Android => remove the library in the right panek
Right click on project folder =>Build Paths => Configure build paths =>In the right panel: the folder relative to the library can be expanded; I manage to remove one of the resources in this expanded fodler but not the others (and consequently not the root folder)
The library (.jar) is still visible in my project above the assets folder and I don't manage to remove it. Below how it looks (cannot be remove by right click and delete (gray)):
Any help would be appreciated !
Maybe You have to go:
right click on your project:
properties > select "Android"
Under "Library", remove the library you want.
It maybe some libraries include other libraries so you couldn't remove it from where you have tried.
Right click on the jar file -> Build Path -> Remove from Build Path
Open settings.gradle and delete:
"include ':librayname'"
Then delete lib file from app Myproject/app folder.
I was able to remove an External Library after following these steps:
Remove compile entry from build.gradle (app)
RESTART Android Studio.
Following steps worked for me :
Right click on JAR file in libs folder
Choose option Refractor and then select Safe Delete Option
Delete this entry from build.gradle --> compile files('libs/)
open Android Studio terminal and execute this command --> gradlew clean
jar file will be deleted but Code you have used from the jar file will still be there in java files. you can manually delete that.

Categories

Resources