Eclipse上的NoClassDefFoundError异常

时间:2012-09-03 14:05:13

标签: android eclipse noclassdeffounderror user-defined-functions

我正在使用Java开发一个Android应用程序,并尝试在我的项目中使用我的用户定义类MarportWS。我已经将它们放到src文件夹中,并且它已经完美编译。但是在运行时我得到的例外是引用该类没有定义。如果您有任何想法,请帮忙。

顺便说一句,问题出现在gateOut函数上,而不是gateIn

这是我的代码:

package com.example.marport;

import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;

public class Giriscikis extends Activity {

    final static String NAMESPACE = "http://webservice.marport.dcat.com/";
    final static String METHOD_NAME2 = "gateIn";
    final static String SOAP_ACTION2 = "http://webservice.marport.dcat.com/gateIn";
    final static String URL = "http://192.168.1.164:8070/mws/services/MarportWebServicePort?wsdl";

    public String denemecikis;
    private EditText cikis;
    private EditText giris;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.giriscikis);

        cikis = (EditText) findViewById(R.id.etCikis);
        giris = (EditText) findViewById(R.id.etGiris);

        SoapObject Request2 = new SoapObject(NAMESPACE, METHOD_NAME2);

        SoapSerializationEnvelope soapEnvelope2 = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        soapEnvelope2.dotNet = false;


        soapEnvelope2.setOutputSoapObject(Request2);

        HttpTransportSE aht = new HttpTransportSE(URL);

        //////////////////////////////////////////////////////// 
        MarportWS temp = new MarportWS();
        try {
            denemecikis = String.valueOf(temp.gateOut().intValue()) ;
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        cikis.setText(denemecikis);
        /////////////////////////////////////////////////////// 

        try {
            aht.call(SOAP_ACTION2, soapEnvelope2);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        try {
            SoapPrimitive result2 = (SoapPrimitive) soapEnvelope2.getResponse();
            giris.setText(result2.toString());
        } catch (SoapFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

日志:

09-03 13:56:32.594: E/AndroidRuntime(751): FATAL EXCEPTION: main
09-03 13:56:32.594: E/AndroidRuntime(751): java.lang.NoClassDefFoundError: com.example.marport.MarportWS
09-03 13:56:32.594: E/AndroidRuntime(751):  at com.example.marport.Giriscikis.onCreate(Giriscikis.java:49)
09-03 13:56:32.594: E/AndroidRuntime(751):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-03 13:56:32.594: E/AndroidRuntime(751):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-03 13:56:32.594: E/AndroidRuntime(751):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-03 13:56:32.594: E/AndroidRuntime(751):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-03 13:56:32.594: E/AndroidRuntime(751):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-03 13:56:32.594: E/AndroidRuntime(751):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-03 13:56:32.594: E/AndroidRuntime(751):  at android.os.Looper.loop(Looper.java:123)
09-03 13:56:32.594: E/AndroidRuntime(751):  at android.app.ActivityThread.main(ActivityThread.java:4627)
09-03 13:56:32.594: E/AndroidRuntime(751):  at java.lang.reflect.Method.invokeNative(Native Method)
09-03 13:56:32.594: E/AndroidRuntime(751):  at java.lang.reflect.Method.invoke(Method.java:521)
09-03 13:56:32.594: E/AndroidRuntime(751):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-03 13:56:32.594: E/AndroidRuntime(751):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-03 13:56:32.594: E/AndroidRuntime(751):  at dalvik.system.NativeStart.main(Native Method)

感谢。

1 个答案:

答案 0 :(得分:0)

我已经回答了一个与您有关的问题。看看here

是的,这是因为您的.jar文件无法正确导入。请按照以下步骤进行操作 -

  1. 将.jar文件放在项目的libs文件夹中。

  2. 将其导入您的项目。而且,GoTo项目 - >属性 - > Java构建路径 - >订单标签。

  3. 检查您的.jar文件是否按1的顺序检查并放置。这是主要的事情。

  4. 希望这些步骤对您有所帮助。看看下面的图片 -

    image