2

うまくいけば、あなたは私の問題で私を助けることができます. アプリケーションが起動時にクラッシュするため、LogCat を使用してエラーを見つけようとしました。タイトルで述べたように、エラーメッセージは次のように述べています。

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

多分私はここで何かを逃した。もう質問を指定できません。私が得たのはコードとエラーメッセージだけです。では、アプリを実行するにはどうすればよいでしょうか。

ご協力いただきありがとうございます。

4

3 に答える 3

3

いくつかの提案

AndroidManifest.xml1)まだ宣言されていない場合は、ファイルでアクティビティを宣言します。

2)開こうとしているようで、質問にアクティビティMainActivity class/Activityを追加AndroidWSDLFrontEndしました。正しいアクティビティを呼び出していることを願っています。マニフェスト/アクティビティ宣言とアクティビティの開始時にそれぞれのクラスの名前を確認してください。

07-29 03:49:46.734: E/AndroidRuntime(837): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.calculate.firsttry.**MainActivity**" // here it says MainActivity not found, Check the name of your activity
于 2013-07-29T04:24:37.047 に答える