How to fully remove an external library in a project? - android

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.

Related

Android studio, how to delete folder with references?

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.

How can i add "Add External Jar" to my project in android

I want to add banner to my project. I have done some work in this regard, but i have problem in adding "Add External jar".
[Right click on my Project -> properties -> Java Build Path -> Libraries -> Add External jar].
Now my problem is, as I click "Add External jar" a new widow(browsing) opens and asking for to open jar file, but I have studied "Android Developer documents" for adding banner in project, there was nothing mentioned about the to open jar file. Now what I have to do, to add "Add External jar" and I could continue my project further.
Yours help would be greatly appreciated.
Thank`s in advance.
How can i add “Add External Jar” to my project in android
For, this i always follow below steps -
Just create a libs folder on my project ->And, copy the .jar file to there.
In your workspace select your project and right click -> on Properties, just go to Java Build Path
Click the Add External jars it'll open the window dialog box -> root your workspace -> And, select your project -> go to libs folder -> choose the .jar file -> Click ok.
Hope these steps helps you.
There should be a jar file that you downloaded that contains he libraries you need. You'll need to select that jarfile for the step that you are doing currently.
It is a good idea to keep that file within your project folder as well. Many people like to keep all of their libraries inside of a folder called libs within their project folder.
I'm not sure what "banner" is, but if it's an Android Project it cannot be added as a JAR. Projects that have resources are not able to be fully externally liked libs.
If indeed this is Android Project you will need to import the existing project into your Eclipse workspace here the steps http://developer.android.com/guide/developing/projects/projects-eclipse.html#SettingUpLibraryProject
Create a folder called "libs" in your project.
Go to that folder using Windows Explorer and copy the .jar file there.
Refresh your project in eclipse and right click on the jar file and select "Add to Build Path" option.

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 add JSoup.jar to my android project?

Very basic, But I don't know, How to add JSoup.jar to my android workspace? If anyone knows, please help me?
Right click on your project > Properties > Java Build Path > Libraries > Add [external] Jars
Create a folder named libs in the root of your project and put your jar files here.
Then go to project Properties, under Java Build Path > Libraries click con Add JARs... and select you jar file, under the libs folder.
Create a folder named libs in the root of your project and put your jar files here. And then right Click the .jar file and click Add as Library and Select app from dropdown menu and click OK
Happy Coding :)
In Android Studio follow the below steps:
Right click on file named app (inside project files in the Android project view)
Click on Open module settings
Inside Project Structure click on the + (New module) symbol on top left corner
Inside create new module select .JAR/.AAR package
Inside create new module select the .jar file to be imported and click finish
Inside Project Structure click on app (below list of Modules)
Select Dependencies click on the +(Add) symbol on top right corner
Then select Module dependency
Select the module name to be imported from the list given in Choose Modules and click ok.
If you want to add jar in specific folder(eg: lib) than do as Francesco said
else
Just right click on project>build path>configure build path>libraries> you have some options to add jar.Which one to use upto you.
Create a folder named libs in the root of your project and put your jar files here. And then right Click the .jar file and click Add as Library and Select app from dropdown menu and click OK
This solved my problem

Why can't android find com.google.gson.Gson

I'm trying to use GSON in my project, but my application is crashing, with logcat saying that com.google.gson.Gson cannot be found. I've put import com.google.gson.Gson on my class files, I have gson in my package explorer, and added it by Right click -> build path -> add libraries. It also shows up in Project->properties->java build path->libraries tab->gson. What have I done wrong?
What worked for me: Check the checkbox next to the lib (gson-2.0.jar) in: 'Project Properties' -> 'Java Build Path' -> 'Order and Export' tab. Then do a clean/build.
This adds the exported=true attribute to the classpath entry
<classpathentry exported="true" kind="lib" path="libs/gson-2.0.jar"/>
Have you put the jar file in the libs folder of the project? If not , try moving it there, creating the folder if required. Should be at the same level as the src folder.
I had a similar issue trying to get an app built and that solved it.
I'm using IntelliJ, not eclipse but here is how I did it:
Download the source files from https://google-gson.googlecode.com/files/google-gson-2.2.4-release.zip
Unpack them
Copy them into the "libs" folder of your project. I did this manually by using the terminal but you can do it by going in your project folder located in your computer. Your Project_Name >app >Libs [paste them here]
Go to your editor (IntelliJ in my case) You should see the the following 3 files in the libs folder of the project structure:
gson-2.2.4.jar
gson-2.2.4-javadoc.jar
gson-2.2.4-sources.jar
Open your build.gradle file and insert the following line in the dependencies section:
compile files('libs/gson-2.2.4.jar', 'libs/gson-2.2.4-javadoc.jar', 'libs/gson-2.2.4-javadoc.jar')
Right click on each of the source files and select "Add as Library..."
Use the following options:
Name: name of the jar file
Level: Project Library
Add to Module: select project your adding to
Rebuild project
Build > Rebuild project
Import and use it!
import com.google.gson.Gson;
I have observed today that it doesn't like when you add your library.
The solution that worked for me was to add it as an external jar only. I have observed it by doing the steps described by author of this post i.e. Properties -> Java Build Path -> Libraries -> Add External JARs and point to the downloaded gson library.
I ran into the same issue (when installed SDK 17) ...
The solution is, that you just put the pure jar files into the "libs" folder (without subfolders).
You also don't need to declare them, android wil find them itself. You may need to do a Project > Clean
I had similar problem, but I guess my requirement was more complicated as the GSON libarary was used by an Android Library Project that my main Android project depended on. I have tried both approaches above but none of them worked for me. If I add the GSON jar file directly to the main Android project it works, but that is not what I wanted.
With a bit of investigation I have realised that the GSON jar does not use any dependencies (third party libraries) itself. So my solution was to copy the source file of the GSON project to my Android Library project's src filder and it worked like a charm. so you can use the Source code rather then the binary code. The source code is part of the download in a jar file, just unzip it.
i'm sure you have copied the jar into "libs",
and also added property> Java Build Path >(tab) Libraries, right?
my issue was stupid...
please check other than Gson jar, if you have two stuffs at least in above tab:
android x.x
Android Dependencies (especially this one, i missed this, eclipse show me an error of "could not find class com.google.gson.xx" )
simply do a project copy will solve this problem...
Do not edit .classpath file directly or even put files into lib folders out of Eclipse.
Instead use the Java Build Path->Order and Export tab to select libraries to be exported in the final deployment unit (eg war/apk)
To be on safer side, do a Project->Clean after you change the build path.
I faced the same thing.But the solution was quite easy,just Right-Click on your project->Properies->Libraries->Add external jars->OK and thats it.It solved my problem.hope it will solve yours as well
If Projct Properties -> Java build path -> Add external jars doesn't work and your project is a web project, try adding the gson jar directly to the server lib folder. Example: for apache Tomcat to apache-tomcat/lib.
I have been trying the same thing and read so many answers and tried so many things but to not vial, but i solved this problem by doing just one click and its simple.
1) Add your .jar file in libs folder make sure its libs not lib
2) Clean and Build your project you will see that file under libs folder
3) right click the file and go to build path and select add to build path
Run your project it will work fine. Hope this helps
I am using Android Studio
I had the same problem I had solve it by
select project press f4 from popup
click app and in dependencies
select file dependency and select the three folders which I had pasted in lib directory

Categories

Resources