I initially thought it was exclusively for official libraries like the support library. However any time I add a custom JAR using the "Add to build path" menu item, it automatically shows up in both "Referenced Libraries" and "Android Private Libraries". One of these is redundant since there is no point in exporting both at build time. Additionally, "Android Private Libraries" cannot be modified so I can't (easily) add java doc or source paths. Not to mention it just seems wrong that a custom JAR is in "Android Private Libraries".
I cannot delete the entry from "Android Private Libraries" to use only "Referenced Libraries" either.
In my case i always add libraries to libs folder.
According to my understanding thats the way its suppose to be. Android Private Library folder references these jars in libs folder. The Android Private Library is used during the creation of apk (probably during the conversion of your java code into dex file).
I don't have any problem with custom jars. They are only in Reference Libraries in my case. I suggest you to look at Order and Export tab in java build path properties.Just check all the custom jars and uncheck all the Android specific libraries. If you want all jars in Reference Libraries then check all jars and clean your project.
you just need to put jar and jardoc to a folder but not the folder "libs".
Then there will be a 'Reference Library',
Then you can add jardoc to jar by properties of jar in Reference Library.
1: New a Folder named sth but not "libs"
like folder named 'lib'.
2: Put your .jar and .jardoc in the new folder
the folder 'lib' in this tutorial
3: Add the jar and jardoc to project.
Then, a 'Reference Libraries' will appear
4: Delete original jar/jardoc.jar in libs (if you've imported them to libs before).
5: add XXXjavadoc.jar to XXX.jar as doc location.
Related
The title might seem confusing (although accurate). Let me explain it in more words:
I have an android Library project, lets call it ProjectA. I also have second android Library project, lets call it ProjectB. The ProjectB and ProjectA are in the same workspace, and ProjectB is referencing ProjectA in it's libraries list (project properties). So ProjectB is using ProjectA.
Now what I want to accomplish is to get a simple jar of the library - ProjectB, and include this jar as external library in my yet another android project (android application this time).
However... when I compile ProjectB, the jar size is way too small (the ProjectA's jar is over 300KB, yet ProjectB's jar is only 14KB), so I'm sure it does not contain ProjectA's in the jar file I find inside bin folder (of the ProjectA). To do a quick math, ProjectB's jar should be ~300KB bigger.
So to repeat, I'd like to have everything the library needs, packed in one jar file (jar file of ProjectB's), so that when I import it into libs of an Android Application I can use it.
Any help here from expierienced Android dev?
If you are searching for the quickest way to do this, in Eclipse highlight your library project, then go to File > Export and under Java select JAR. From there, you can select a multitude of options, including which other referenced projects should be exported as part of the JAR.
Commonsware is correct, it's just a JAR, there is no magic. If you need a build system option then consider using Ant or Gradle to package the JAR for you. Do not however, try to use what is in the bin folder, as that is not meant for you to use.
You need to make sure you export the library in your Build Path. For Eclipse, you can Right-click on the project, choose "Build Path" > "Configure Build Path", go to the "Order and Export" tab on the right side, and make sure that your library is checked in the list there (it might be contained in one of several library groups if your Project has multiple dependencies).
I am beginner in android. My client gives me a sample project as reference. In that project have an extra folder 'android dependency’ and that contain a jar file 'annotation.jar' .How can I add the very same jar to my project dependency folder? Any one please helps me!
Find "libs" directory in your project. Those will contain physically those jar files. Android Dependency will indicate that how many libraries are associated with current project.
When you find "libs" directory, right click on jar files, and you will find "Build Path" and then add them to build path. will solve your problem.
Edit
Go to the SDK Manager within eclipse (Window --> Android SDK Manager) and installed the Android Support Package which is found in the Extras folder.
Follow this: Project->RightClick->Properties->BuildPath and Add External jar then browse for particular jar file and Add.
Just copy it in your libs folder and refresh your project. Remember it should be libs not lib. Also remove it from your "external jars" path from Project->RightClick->Properties->BuildPath
Edit :
And also try this
Also remove android.jar file to your build path.
I want to use a svg-android library to work with *.svg files in Android. For the same, I've installed the apache ant, created a folder in workspace called: SVGAndroid and then added
android.library.reference.1=C:\Android\workspace\SVGAndroid
to project.properties file.
There were no documentation for functions in ReadMe, so I'm wondering if the installation correct or not, how to reinstall an external lib in the second case and where are the examples of using svg-android?
For your including of the project, just include the project into your workspace and in your respective application under the properties of that project just add a dependency on a library that references svgandroid. Make SURE to include the files and ensure that the compile class files are present in the final output of the apk. This typically means that you add the project to your build path/order.
Another approach is to just take the entire project and compile it into a jar file and then include that jar in your libs folder and add that dependency on the jar file of that respective project to your core application.
Useful links
How can I use external JARs in an Android project?
I would rather suggest to not add the path to the project manually, but from Project Properties -> Android and you will have a list with all the library projects in the workspace from which you can choose the desired project.
Also I suggest adding in project.properties the following line:
manifestmerger.enabled=true
in order to have all the AndroidManifest.xml files of the referenced library projects merged into the main project's manifest.
If you want to include a library file in to your project follow the below steps;
Download a jar file and save it in any folder.
open your project.
Right click--> Build path--> Add External Archives---> Add your external jar file to your project
I am trying to compile a java project which makes uses of android libraries. The project I am using is checked out from a svn repository.
In order to take a use of that project I am required to define some jar files and libraries for that project.
Here are the files that I need to make sure they are defined:
•"lib/apache-mime4j-0.4.jar" : Jar
•"lib/httpmime-4.0-beta1.jar" : Jar
•"lib/slf4j-android-1.5.8.jar" : Jar
•"JUnit 4.libraryclasspath" : Library
•"ANDROID_SDK_PLATFORM/android.jar" : var
•"Java JRE System Library" : Library
Does anyone have any idea about what should I do to define these files? I am a noob here.I do not know which selection should I choose When I clicked "project -> properties -> java build path -> libraries"
For example if I want to define the first jar file, there are a "add external jar" and a "add libraries" selections.
However you can see a "lib" here in front of the "apache-mime4j0.4.jar file" in this list above..
So I don't understand if it is asking me to add a jar file or the librabry.. I am getting very confused about this.
And also How can I do anything with "JUnit 4.libraryclasspath" file? I think it is a classpath file so I cannot either choose "add jar files" or "add libraries" to define it..
Hope someone has any knowledge about this and I will be very appreciated!
I think You are unable to include the files due to SVN path but will discuss it later.At first we look how to add jar files
Right click on your project in which you want to add the jars
1.select build path and then "configure build path"
2.click on "Libraries" tab
3.Now click on Add external jars (as your all jars files would be placed in some directory outside the project folder or anywhere else)
4.Select these jars and now do OK ... Now these jars are in your class path and you can use these files.
Now another thing, As You told that you are using svn , It means many of other developers are also using the same project then it is compulsory that all of you have same path of jars in your systems for instance in Dev1 PC the jar if the jar file is placed in d:/lib/jars folder then all other DEV2 , DEV3 ... DEVn must have d:/lib/jars folder and their jars must be placed there and you have to add these jars from d:/libs/jars
Last thing , If you are still unable to understand the solution and remove the bugs then simply do this.
Copy all jar files manually (ctrl+c) and copy to lib folder in your project as i have seen that in your project the person who commits the code place them there.
after then , right click on your project and click refresh(as it is bad practice to put jar files in project by creating folder like lib etc unless it is a web project)
Let me know if anything is unclear about this
I am going to create a library project which has several dependencies (jar files).
I am confused because I've seen some android projects which has LIB or LIBS folder under project root folder (together with bin,gen,res,src.etc..)
Even I add LIB or LIBS folder, then put the jar files on it. Still need to set the project properties in order to recognize the added jar files by doing Project Properties => Java Build Path => Libraries tab => Add JARs... button.
I am using Eclipse with Android Plugin.
When I add LIBS, it will appear the Android logo on the top of the LIBS folder. It is recognized by the plugin but still need to set it in the project properties (same the above adding JARs)
Which is the correct directory structure for Android Project?
If you use the Android command line to create your project, it'll default to libs/. It turns out that the Android Ant tasks are set to look in libs/ by default.
See $ANDROID_HOME/tools/ant/main_rules.xml:
<property name="jar.libs.dir" value="libs" />
If you just care about Eclipse, you can use whatever you want.
In newer revisions of ADT (revision 17 onwards), the Ant-based build system and the Eclipse plug-in are aligned so that they behave the same way. This means, by default, only the jars that are present in the libs folder are included in the final apk file. These jars would automatically appear under "Android Dependencies" in your Eclipse project.
For more details please refer here. http://tools.android.com/recent/dealingwithdependenciesinandroidprojects
It doesn't matter actually. It can be lib or libs. Whether jar files are in lib or in libs, you just need to do right click on project, select "Build path => Add to build path" , thats it.
Citing: http://tools.android.com/recent/dealingwithdependenciesinandroidprojects
If you are still referencing jar libraries manually instead of putting them under libs/ be aware of the following:
If the project is a Library project, these jar libraries will not be automatically visible to application projects. You should really move these to libs/
If the project is an application, this can work but you must make sure to mark the jar files as exported.