How do I import jars in an android project?

Go To StackoverFlow.com

2

I am using Eclipse. I have followed multiple tutorials for setting up ksoap on my android project. The ksoap2 jar file is included in my build path. The tutorial includes the lines below.

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    SoapSerializationEnvelope envelope = new SoapSerializaionEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

SoapObject is underlined in red and when I hover over it I'm not prompted with an option to import it. Create class, Create interface, etc. are options.

Any help is greatly appreciated.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

2012-04-04 23:34
by alockrem
Make sure you are on the latest version of the Android developer tools and Eclipse ADT plugin - CommonsWare 2012-04-04 23:56
I dont have a Referenced Libraries folder in any of my projects. HAve you configured that lib in multiple places? It should only be set in one place [java build path - kenyu73 2012-04-04 23:58
I added a screenshot of that as well. Everything appears to be up-to-date - alockrem 2012-04-04 23:58
This is the first time I have attempted to configure this lib with any project - alockrem 2012-04-05 00:02


0

Click on the "Order and Import" tab and make sure the checkbox next to it is checked.

EDIT:

Try this: Please make sure that you have included all of these:

import org.ksoap2.*;

import org.ksoap2.serialization.KvmSerializable;

import org.ksoap2.serialization.Marshal;

import org.ksoap2.serialization.PropertyInfo;

import org.ksoap2.serialization.SoapObject;

import org.ksoap2.serialization.SoapPrimitive;

import org.ksoap2.serialization.SoapSerializationEnvelope;

import org.ksoap2.transport.AndroidHttpTransport;

import org.ksoap2.transport.HttpTransportSE;

import org.xmlpull.v1.XmlPullParserException;

Hope that helps!

LAST EDIT: It seems we have set up everything correctly. Re-download the jar file from this source. I feel that yours is not correct. Here: http://sourceforge.net/projects/ksoap2/

enter image description here

2012-04-04 23:56
by EGHDK
I dont think those need to be checked, at least I dont have those checked for my AdMob jar - kenyu73 2012-04-05 00:00
THEY HAVE TO BE CHECKED = - EGHDK 2012-04-05 00:01
It wasn't checked. I checked it and it still is not working. I added a screenshot to my original post for your referenc - alockrem 2012-04-05 00:01
Change libs folder to lib. Then right click on your Project. Click Properties. Hit java build path. Click Libraries tab. Click Add Jars. Then add your jar from the "lib" folder, and then click Order and Export and check it off. That's it - EGHDK 2012-04-05 00:04
If you are using ADT v17 you need to order and export. http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-1 - EGHDK 2012-04-05 00:07
I believe you. I have followed your instructions and it is exactly the same. I have uploaded an updated screenshot. Please let me know what to do next - alockrem 2012-04-05 00:09
I updated my answer. Please look at it - EGHDK 2012-04-05 00:15
The imports fail because org.ksoap2 cannot be resolved. (updated screenshot on original post). BTW - I really appreciate your help. I'm sure this is just as frustrating for you as it is for me - alockrem 2012-04-05 00:20
let us continue this discussion in chatalockrem 2012-04-05 00:23


1

I copy the jars into my project's libs folder. Make the libs dir if its not there. Go into Eclipse select your project, right-click/refresh (F5 works?). You'll see the lib folder show up in your files panel.

Once the lib displays in your project, go into project->properties->java build path [add jars]. You should see your lib folder with the jar in that folder. Select it and you should be good.

Once that is setup, the project should see it... try using clean.

enter image description here

enter image description here

2012-04-04 23:39
by kenyu73
That is exactly what I have done. All except "try using clean". I'm not sure what that means - alockrem 2012-04-04 23:46
@alockrem project->clean.. - kenyu73 2012-04-04 23:47
I tried that an nothing changed. I have uploaded a screenshot to my original post. Maybe you'll see something I have missed - alockrem 2012-04-04 23:51
Ads