希望你能帮助我解决我的问题。我的应用程序在启动时崩溃,所以我尝试使用 LogCat 来查找错误。如标题中所述,errormassage 说:
07-29 03:49:46.734: E/AndroidRuntime(837): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.calculate.firsttry/com.example.calculate.firsttry.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.calculate.firsttry.MainActivity" on path: /data/app/com.example.calculate.firsttry-1.apk
07-29 03:49:46.734: E/AndroidRuntime(837): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.calculate.firsttry.MainActivity" on path: /data/app/com.example.calculate.firsttry-1.apk
所以好像我在某处错过了一些声明。问题是,我不知道在哪里。这不是我的第一个应用程序,我以为我已经重复了我之前做的每一步。
这是我的应用程序的代码:
package com.example.calculate.firsttry;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class AndroidWSDLFrontEnd extends Activity {
private String METHOD_NAME = "add"; // our webservice method name
private String NAMESPACE = "http://calculator.backend.org";;
private String SOAP_ACTION = NAMESPACE + METHOD_NAME; // NAMESPACE + method name
private static final String URL = "http://10.35.108.154:8080/AndroidBackend/services/Calculator?wsdl";;// you must use ipaddress here, don’t use Hostname or localhost
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView) findViewById(R.id.txtAddition);
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("a", 5);
request.addProperty("b", 15);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION,envelope);
Object result = envelope.getResponse();
System.out.println("Result: " + result.toString());
((TextView) findViewById (R.id.txtAddition)).setText("Addition :" +result.toString());
} catch (Exception E) {
E.printStackTrace();
((TextView) findViewById (R.id.txtAddition)).setText("ERROR: " + E.getClass().getName() + "," + E.getMessage());
}
}
}
也许我在这里错过了一些东西。我不能再指定问题了。我得到的只是代码和错误消息。那么如何让我的应用程序运行呢?
谢谢你的帮助。