How do I import jars in an android project?

不羁的心 提交于 2019-11-28 09:33:25

问题


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.


回答1:


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/




回答2:


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.



来源:https://stackoverflow.com/questions/10020740/how-do-i-import-jars-in-an-android-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!