android - 无法在 Android 库文件中找到类

标签 android shared-libraries classnotfoundexception

我创建了一个非常简单的 Android 应用程序来处理功能。在应用程序中,我想调用 Web 服务客户端来检索和显示一些数据。我认为我已经成功导入并引用了 jar 文件(即库)。它似乎成功地实例化了该类,但是当该类引用 jar/库中的另一个类时,它会抛出 找不到类 错误。有任何想法吗???我还能提供什么帮助回答???

这是我的代码:

package mhcs.android.ehd;

import mhcs.services.client.EHD.EHDClient;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class GetTicketDescription extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        EHDClient client = new EHDClient();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        String title = getString(R.string.title);
        setTitle(title); // done so that we can change the default title
        //get handles to editText and button widgets
        final EditText eText = (EditText) findViewById(R.id.editText1);
        final Button button = (Button) findViewById(R.id.button1);
        eText.setText(client.getTicketDescription("MMLZ-8LVRMK"));

        button.setOnClickListener(new Button.OnClickListener(){
            @Override
            public void onClick(View v) {
                //get the String entered into the editText widget
                CharSequence editText = eText.getText();
                //display the toast
                Toast.makeText(GetTicketDescription.this, editText, Toast.LENGTH_LONG).show();
            }
        });
    }
}

这里是错误:

D/dalvikvm(538): Not late-enabling CheckJNI (already on)
I/dalvikvm(538): threadid=3: reacting to signal 3
I/dalvikvm(538): Wrote stack traces to '/data/anr/traces.txt'
W/dalvikvm(538): Unable to resolve superclass of Lorg/tempuri/EHDLookupService; (73)
W/dalvikvm(538): Link of class 'Lorg/tempuri/EHDLookupService;' failed
E/dalvikvm(538): Could not find class 'org.tempuri.EHDLookupService', referenced from method mhcs.services.client.EHD.EHDClient.<init>
W/dalvikvm(538): VFY: unable to resolve new-instance 93 (Lorg/tempuri/EHDLookupService;) in Lmhcs/services/client/EHD/EHDClient;
D/dalvikvm(538): VFY: replacing opcode 0x22 at 0x0003
W/dalvikvm(538): Unable to resolve superclass of Lorg/tempuri/EHDLookupService; (73)
W/dalvikvm(538): Link of class 'Lorg/tempuri/EHDLookupService;' failed
W/dalvikvm(538): Unable to resolve superclass of Lorg/tempuri/EHDLookupService; (73)
W/dalvikvm(538): Link of class 'Lorg/tempuri/EHDLookupService;' failed
I/dalvikvm(538): Could not find method org.tempuri.EHDLookupService.getBasicHttpBindingIEHDLookupService, referenced from method mhcs.services.client.EHD.EHDClient.<init>
W/dalvikvm(538): VFY: unable to resolve virtual method 112: Lorg/tempuri/EHDLookupService;.getBasicHttpBindingIEHDLookupService ()Lorg/tempuri/IEHDLookupService;
D/dalvikvm(538): VFY: replacing opcode 0x6e at 0x001c
W/dalvikvm(538): VFY: unable to find class referenced in signature (Ljavax/xml/bind/JAXBElement;)
I/dalvikvm(538): Could not find method javax.xml.bind.JAXBElement.getValue, referenced from method mhcs.services.client.EHD.EHDClient.getAssigneeTickets
W/dalvikvm(538): VFY: unable to resolve virtual method 42: Ljavax/xml/bind/JAXBElement;.getValue ()Ljava/lang/Object;
D/dalvikvm(538): VFY: replacing opcode 0x6e at 0x0026
W/dalvikvm(538): VFY: unable to find class referenced in signature (Ljavax/xml/bind/JAXBElement;)
I/dalvikvm(538): Could not find method javax.xml.bind.JAXBElement.getValue, referenced from method mhcs.services.client.EHD.EHDClient.getTicketDescription
W/dalvikvm(538): VFY: unable to resolve virtual method 42: Ljavax/xml/bind/JAXBElement;.getValue ()Ljava/lang/Object;
D/dalvikvm(538): VFY: replacing opcode 0x6e at 0x000b
W/dalvikvm(538): Unable to resolve superclass of Lorg/tempuri/EHDLookupService; (73)
W/dalvikvm(538): Link of class 'Lorg/tempuri/EHDLookupService;' failed
D/dalvikvm(538): DexOpt: unable to opt direct call 0x006b at 0x15 in Lmhcs/services/client/EHD/EHDClient;.<init>
D/AndroidRuntime(538): Shutting down VM
W/dalvikvm(538): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)

E/AndroidRuntime(538): FATAL EXCEPTION: main
E/AndroidRuntime(538): java.lang.NoClassDefFoundError: org.tempuri.EHDLookupService
E/AndroidRuntime(538):      at mhcs.services.client.EHD.EHDClient.<init>(EHDClient.java:25)
E/AndroidRuntime(538):      at mhcs.android.ehd.GetTicketDescription.onCreate(GetTicketDescription.java:15)
E/AndroidRuntime(538):      at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime(538):      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime(538):      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime(538):      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime(538):      at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime(538):      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime(538):      at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(538):      at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(538):      at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime(538):      at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(538):      at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(538):      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(538):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(538):      at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(538): threadid=3: reacting to signal 3
I/dalvikvm(538): Wrote stack traces to '/data/anr/traces.txt'

注意:我了解 org/tempuri 的问题并会更正。

(我是新用户,无法发布我的工作区图片)

最佳答案

  1. 查找属性 -> Java 构建路径 -> 订购和导出
  2. 更改 Android 依赖项顺序

关于android - 无法在 Android 库文件中找到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10710693/

相关文章:

android - Watchdog !@Sync error 表示什么?

c++ - 我该如何剥离符号表?

linux - ldconfig 仅加载 .so 文件

使用 URLClassLoader 加载类时出现 java.lang.ClassNotFoundException

android - 导入示例 Libgdx 游戏

android - 在 4*3 的网格中排列 12 个 RadioButton

python - 在 ubuntu 中嵌入 python 时出现段错误

tomcat - 从 Cygwin 使用 Tomcat,接收 ClassNotFoundException,

java - 如何解决 ClassNotFoundException?

安卓SDK版本