How can i add "Add External Jar" to my project in android - 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.

Related

Problems including library project into build path

I am trying to follow the steps of setting up a v7 support library as they are listed on the android development website.
Create a library project and ensure the required JAR files are included in the project's build path
I get stuck on step 5 where I am supposed to right click the JAR files and choose "Build Path". This option is missing. I have checked other questions related to this such as this one>>> Question
but none of the listed solutions seem to work for me. Either that or I do not see the options that the posters are referring to on the menus. Has anyone had this problem? Where did I go wrong?
I need this for an android project.
If you are doing in eclipse, then you can go to ProjectName -> Right click on it -> Goto Properties -> Goto Java Build Path -> Go to Library -> Choose Add Jars option if jar is in same project or choose Add External JARs if jar is outside the project folder.
If you have already copied the JAR file to libs/ directory of your project then choose the option of Add JARs and browse to the libs folder where you've copied the jar. Select it and press okay. It should get included in your project. Hope this helps else please comment.

How to use an external java project in an android application

i've been struggling with this issue for a couple of days now...
ill explain my problem in a nutshell....
i have a simple java project (not android library or something more complex) which i want to use as my model..
lets assum it is called mymodel and it has a simple class Model.
i also have an android application myandroidapp and in the main activity i want to create an instance of the class Model.
I can add the mymodel as a project to the build path and compile but when i run this application it throws class not found exception. how can i make it work?
please help.
thanks
Step #1: Create a JAR based on your "simple java project"
Step #2: Put the JAR in the libs/ directory of your Android project
And you're done.
Never mess with the build path of an Android Eclipse project manually.
In Eclipse, you can follow the following steps:
Creating JAR file
Right-click on the root of the mymodel project and click on 'Export...'
In the window that appears, expand the 'Java' category/folder, choose 'JAR file' and click 'Next'
In the next window, choose the options you desire, especially pay attention to where the 'export destination' is. When you're done, click on 'Finish'. The JAR file will now be located at the 'export destination'.
Adding JAR to Android project
In your android project (myandroidapp), copy the JAR file into the libs/ folder. You can do this by simply copy and pasting or dragging and dropping etc.
Then, right-click on the JAR file that is now in the libs folder, go on 'Build Path' and from the menu that appears, click on 'Add to Build Path'
You should now be able to use this JAR file in your Android project.

how to include jar files in my eclipse project

I'm new to android and java. I downloaded the GSON library for use in my android project which exists in Eclipse. I lookup instructions on how to use the jar file in my project and it says...
Quote...
You can use a third party JAR in your application by adding it to your Eclipse project as follows:
In the Package Explorer panel, right-click on your project and select Properties.
Select Java Build Path, then the tab Libraries.
Press the Add External JARs... button and select the JAR file.
Alternatively, if you want to include third party JARs with your package, create a new directory for them within your project and select Add Library... instead.
It is not necessary to put external JARs in the assets folder
...UnQuote
I'm afraid that I don't know the difference between "using a 3rd party jar in my project" and "include third party jars with my package." I want to be able to use the GSON methods in my Android phone application and, of course, have the capability deployed in my .apk.
So, Which do I want to do?
Thanks, Gary
add the jar to your libs folder in your project.
open eclipse go to package explorer
right click on your project and select project properties
click on java Build path in the bar on the left hand side of the popup
select the libraries tab
select the "Add External Jar File" and navigate to your JAR file
best of luck =)
click Properties
left select Build path
Than add jar, and do not use the external libs, unless it is really required.
You have to copy the jar to your project to find it with "Add jars"
Right click onto your main project in the Project Explorer
Open properties option, found at the bottom of the context menu
A dialog box opens from which you select the Android option
Remove the old .jar file, click on ADD to add a new .jar file and select your the file you want to add
You're done!

Adding jars to classpath, Eclipse, Android

Currently, I go to properties-> build path-> libraries -> and then add external jars to my classpath, I know this is the correct way to do this, for java at least. However, the issue is I am running it on the Android SDK 2.1. When I run the program, I do not think the android emulator can "find" the .jars in the classpath. Is this possible? If so, which folder do I put the jars before adding them to my classpath?
You can try doing it in eclipse by
Right Click the jar --> Build Path --> Add to build path
1) Go to your Finder / Explorer and select your .jar files
2) Drag your .jar files into Eclipse, (make sure to put them in your desired Project)
3) right click on each jar -> "build path" -> "add to build path"
What is the output of the LogCat?
if you are using native code in your projects you must include the so files in libs->armeabi folder. stuff like box2d, chipmunk, xml2, etc...

How to use and package a JAR file with my Android app?

I have an API in the form of a JAR that I would like to use in my Android app. Not sure if it should be part of the project in Eclipse or kept separate and added to the project properties. This JAR also needs to be packaged with the application, so how is that done for Android apps?
As explained by this SO question:
Your Project -> right click -> Import -> Archive File -> yourjar.jar
Your Project -> right click -> Properties -> Java Build Path -> Libraries -> Add Jar -> yourjar.jar
You must add it as "external JAR" files, and set the "Order and Export" in your Eclipse project.
Update February 2012:
Pacerier mentions in the comment having an issue (ClassNotFound) even though he did declare the library.
He had:
However, the solution was simple:
Over 1 hour wasted. Man was I pissed!
Solution: make sure your JAR is compiled with 1.6 and not 1.7.
Argh
Thanks to VonC for pointing me in the right direction. I had the same symptoms but for a different library (I needed to add org.apache.commons.codec.binary.Base64 for an Android project). The solution that worked for me was SLIGHTLY different. Herewith the steps that I followed:
Download library from http://commons.apache.org/codec/download_codec.cgi
Extract commons-codec-1.6.jar from the tarball and copy to a local
folder
In eclipse:
right-click project name
choose "Properties" from context menu
on "Libraries" tab, select "Add External JARs..."
navigate to and select commons-codec-1.6.jar from the location you extracted it to your local drive
The jar file will now appear under "referenced Libraries" in your Package Explorer and you will be able to reference the library in your code.

Categories

Resources