0

I'm developing an Android application using Java and trying to use my user-defined class, MarportWS on my project. I already put them to the src folder, and it is perfectly compiled. However in runtime I'm getting the exception adducing that the class is not defined. Please help if you have any idea.

By the way, the problem comes for gateOut function, not gateIn

Here is my code:

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();
        }
    }

}

And the logs:

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)

Thanks.

Yotam Omer
  • 15,310
  • 11
  • 62
  • 65
skynyrd
  • 942
  • 4
  • 14
  • 34
  • Have you declared `MarportWS` in `Androidmanifest.xml` file? – Praveenkumar Sep 03 '12 at 14:06
  • Am I supposed to add that to the Androidmanifest? Because it is only a Java class and it doesn't include anything about Android programming (It doesn't extend Activity) – skynyrd Sep 03 '12 at 14:09
  • Okay. Then, take a look at my answer. If you're using any external `.jar` files in your app. – Praveenkumar Sep 03 '12 at 14:10
  • I would clean the project, make sure it compiles, make sure there is no exclusion rules in the classpath, make sure the project is compiled against the proper sdk (no java 7). If it still doesn't work, I don't know – njzk2 Sep 03 '12 at 14:18

1 Answers1

0

I already answered a question that is related with you. Have a look at here

Yes, this because of your .jar file didn't import properly. Follow below steps -

  1. Place your .jar file in your project's libs folder.

  2. Import it into your project. And, GoTo project -> properties -> Java build path -> order tab.

  3. Check, whether your .jar file checked and placed in order of 1st. This is the main thing.

Hope these steps helps you. Have a look at below image -

image

Community
  • 1
  • 1
Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
  • which makes no sense given that the question is related to a source file placed in the src folder. – njzk2 Sep 03 '12 at 14:17
  • I did all things but another error comes: "[2012-09-03 17:25:05 - Marport_yeni] Conversion to Dalvik format failed with error 1" – skynyrd Sep 03 '12 at 14:26
  • @AnılSelimSürmeli Have you placed your `.jar` files into `libs` folder only? – Praveenkumar Sep 03 '12 at 14:28
  • The other error is about two jar files are in the same project but I already deleted one of them. The other one placed in Android Dependencies cannot be deleted. – skynyrd Sep 03 '12 at 14:28
  • Yes I placed them to the libs. – skynyrd Sep 03 '12 at 14:29