I want to use library from openCV named "opencv library -2.4.3" , I install all what it needs , and now openCV tutorials work. So I need add the same openCV library to my project for use.
QUESTION
How to add opencv "library -2.4.3" from another project to mine's folder named Android Dependencies
Thanks in advance
Create a libs folder (/libs) in your project's root folder.
Copy the wanted jar to it.
It will be added to Android dependencies.
You have to click on on the project properties (Right Click -> Properties) and add it as dependency there.
I just did this with a project, using eclipse 4.2.1. As with the other answerer, all I had to do was create a folder called "libs/" in my project, and it auto-updated the Android Dependencies list. Are you copying and pasting inside of eclipse?
I moved the file to that folder using the file system, outside of eclipse.
This link describes how the libs folder gets added to Android Dependencies:
http://tools.android.com/recent/dealingwithdependenciesinandroidprojects
Right click on project
Select Properties
Click on Android on left menu
Click on Add
Please select a Library Project
The jar will go into Android Dependencies.
If you add the jar directly to your project under libs or using build path, then it goes under Android Private Libraries.
Both methods works but referencing a library project can have benefits if you want to alter the code of the library during development.
Related
I'm trying to use
Android PagerSlidingTabStrip v1.0.1library
in my project but, after I import the project as existing code in work space I get to project
the Mainactivity and library and and the library is a dependency to the Mainactivity
but it seems that library project doesn't recognized as local library
so what i did is
1- I tried to make a jar file called library.jar from the library project
and I imported as a external jar so that fixed my import but when I try to use PagerSlidingTabStrip object it says missing reference
and beside that there is res folder couldn't be loaded .
2- I follow this How to add a Library Project to a android project
and I did like what the accepted answer said but it still didn't work for me .
This is how I added the library project
That what I got in project libraries
I tried to use this dependency in build.gradle
dependencies {
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
}
but it didn't work
i added before sherlock to eclipse so when i added it inside the root folder
a bin folder created and inside it there are a jar file and that's
doesn't happen with library so i think here is the problem
any help?
From properties window select option android scroll down, below library heading click the add button and select library project.
I was facing the same issue but soon i came to know that there was support library missing from Library project.
Add support library and clean build the library project and then add it in your project
Do the following:
File->New->Other
Select Android Project
Select "Create Project from existing source"
Click "Browse..." button and navigate to "PagerSlidingTabStrip-master" folder which you have downloaded from https://github.com/astuetz/PagerSlidingTabStrip
Check "library"! (Uncheck "sample"). Make sure "Copy to Workspace" is checked as well.
Click Finish. Now "library" is project in your workspace.
Right-click on your project -> Properties
In Android -> Library section, click "Add"
Select recently added "library" project, click Ok and you're all set.
Iam trying to reference a Android project library to my application. I do this:-
1)File->Import->General->Existing project into workspace->Select project library->check copy to workspace.
2)Right click on project->Properties->Android-> Add-> Select project library-> Apply-> ok.
But when I again check if the library is added I get the following:-
How do I resolve this?
Make sure that your library has the same location with your project source files.
It means that if your source is on your workspace , then your library should add into workspace. If not, you should copy your lib into same folder with source then mount it again.
Make sure the library project is checked as a library.
Go to the library projects BuildConfig -> Android -> Check "is library"
Make sure your project and the library project have the same target/min SDK versions.
It's also a good idea to clean your workspace and Build the library project - Right click on library project -> "Build Project"
Try this answer:
The project name needs match the folder name on the file system. What you are seeing in the Project Properties->Android->Library Reference is a relative file system path.
Reference:
In eclipse, unable to reference an android library project in another android project
Thanks to archie-bpgc for comment
i am also facing this problem i have solve this problem like
when import lib in to workspace tick mark as show in picture (basically library project and your project both are in same workspace)
now add lib to your project and clean project
you need to import the project to workspace and the library file into the same workspace.
Then you will not face this error. Kindly the root cause is not known. But this method works.
After all this .. one more way is you can alter the project properties last line where the library file path is specified.
Thank you.
I added the Google Gson jar file to my Android project by copying and pasting the gson-2.2.4 jar file to the libs folder and then right clicked on the Jar file and then select Build Path > Add to Build Path(I followed this tutorial). Then everything worked fine for me with this jar file, but after pushing to github, when my friends pulling this project, they said that all code relevant to that Gson jar file shows errors. How could I fix this?
Problem 1 : Jar doesnt exist. You probably forgot to add, commit and push your changes to github after adding the jar.
Problem 2 : Jar exists but unrecognised. Ask your friends to remove the existing library from java build path using project properties and add again.
You can create a library project which contains the jar file, and then add this library to your project.
Create library project in eclipse:
File->New->Android application project->Next->Check Mark this porject as a library,
uncheck Create custom launcher icon and Create activity->Finish
Add the library to your project:
Right click your project->Properties->Android->Add->Select the library project you created
->Apply->OK
After finishing these two, you should be able to use Gson, and when pushing your project,
remember to push the library project as well.
I imported the library into eclipse by going to File>Import>Existing android Code> etc
and now i have an extra project called "library" in my workspace
Then I right clicked on the project i want to implement this library to and clicked properties, added the library project, as shown in the screenshot below. But when I click Apply/Ok i get a jar dependency error, does anyone know how I can properly use the slidingmenu library in my app? Thanks
Jar mismatches are usually due to the support v4 library jar file being in both your project and the library. To fix this, make sure the entire project and its libraries has 1 copy of the jar by deleting any others. Afterwards, reference that one copy by right clicking your project and adding that copy as an external archive.
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