gpt4 book ai didi

Android 应用程序在启动时崩溃,Logcat : Didn't find class "[package name]" at/data/app/[package name]

转载 作者:太空狗 更新时间:2023-10-29 16:40:56 25 4
gpt4 key购买 nike

希望你能帮我解决我的问题。我的应用程序在启动时崩溃,所以我尝试使用 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());
}
}
}

也许我在这里漏掉了什么。我不能再具体说明问题了。我得到的只是代码和错误消息。那么如何让我的应用程序运行呢?

感谢您的帮助。

最佳答案

一些建议

1) 如果尚未声明,请在 AndroidManifest.xml 文件中声明 Activity。

2) 看来你正在尝试打开 MainActivity class/Activity 并且你在问题中添加了 AndroidWSDLFrontEnd Activity ,希望你打电话正确的 Activity,在 Manifest/ActivityDeclararion 和启动 Activity 时检查各个类的名称。

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

关于Android 应用程序在启动时崩溃,Logcat : Didn't find class "[package name]" at/data/app/[package name],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17915974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com