Unable to find classes in Android library file
Asked Answered
K

4

1

I have created a very simple Android app just to work with functionality. Within the app I would like to call a web service client to retrieve and display some data. I think I have succesfully imported and referenced the jar file (i.e. library). It appears to be instantiating the class successfully but when that class is referencing another class within the jar/library it throws a class not found error. Any ideas??? Anything else I can provide to help answer???

Here is my code:

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

Here is the error:

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'

Note: I understand the issue with org/tempuri and will correct.

(Can't post image of my workspace as I am a new user)

Kreindler answered 22/5, 2012 at 21:50 Comment(1)
This solution worked for me.Sebrinasebum
W
2
  1. Find Properties -> Java Build Path -> Order and Export
  2. Change Android Dependencies order
Whereat answered 24/5, 2013 at 2:10 Comment(0)
S
0

Try to create a new folder called libs under your project and put the .jar file there...

Skylab answered 22/5, 2012 at 22:36 Comment(6)
Also make sure the jar is checked in the Java build path under the project propertiesSteading
Thanks for both of those suggestions. However, I had done both of those. It appears to be working in that I can instantiate a class from the jar but that class cannot seem to find other classes in that jar.Kreindler
@mbadtk, Why do you say that?Skylab
The error I'm getting says "Could not find class 'org.tempuri.EHDLookupService', referenced from method mhcs.services.client.EHD.EHDClient.<init>". I read that to say it can find EHDClient (in the jar library file) but when that class tries to use EHDLookupService (also in the jar library file) it can't find that class. If I'm misinterpreting the error please call me on that.Kreindler
Just to further prove that is was using the library I modified the base class to add a System.out to dump some text within the base class itself. It is, in fact calling that base class (as I can see the added text in the logs) but it is not able to see other classes in same jar but different packages.Kreindler
@mbadtk, Sorry but I don't know what could be the problem...:(Skylab
L
0

I had the same problem, I tried to mark the Android Private Libraries under Order and Export and it didn't work for me. Then I noticed that my libs folder wasn't referenced under the Java Build Path. So I just added it to Libraries and it worked.

Lodie answered 27/6, 2013 at 21:50 Comment(0)
O
0

Go to Project> Build Path >Configure Build Path

Check the Libraries you wanted and hit ok

Overreact answered 13/9, 2014 at 19:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.