开发者

Android "java.lang.noclassdeffounderror" exception

I have a android webservice client application. I am trying to use the java standard WS library support. I have stripped the application down to the minimum, as shown below, to try and isolate the issue. Below is the application,

package fau.edu.cse;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class ClassMap extends Activity {

    TextView displayObject;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        // Build Screen Display String
        String screenString = "Program Started\n\n";

        // Set up the display
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        displayObject = (TextView)findViewById(R.id.TextView01);

        screenString = screenString + "Inflate Disaplay\n\n";

        try {
        // Set up Soap Service
        TempConvertSoap service = new TempConvert().getTempConvertSoap();

        // Successful Soap Object Build
        screenString = screenString + "SOAP Object Correctly Build\n\n";

        // Display Response
        displayObject.setText(screenString);
        }
        catch(Throwable e){
    e.printStackTrace();
    displayObject.setText(screenString +"Try Error...\n" + e.toString());
        }
    }
}

The classes tempConvert and tempConvertSoap are in the package fau.edu.cse. I have included the java SE javax libraries in the java build pasth. When the android application tries to create the "service" object I get a "java.lang.noclassdeffounderror" exception. The two classes tempConvertSoap and TempConvet() are generated by wsimport. I am also using several libraries from javax.jws.. and javax.xml.ws.. Of course the application compiles without error and loads correctly. I know the application is running becouse my "try/catch" routine is successfully catching the error and printing it out. Here is what is in the logcat says (notice that it cannot find TempConvert),

06-12 22:58:39.340: WARN/dalvikvm(200): Unable to resolve superclass of Lfau/edu/cse/TempConvert; (53)
06-12 22:58:39.340: WARN/dalvikvm(200): Link of class 'Lfau/edu/cse/TempConvert;' failed
06-12 22:58:39.340: ERROR/dalvikvm(200): Could not find class 'fau.edu.cse.Tem开发者_C百科pConvert', referenced from method fau.edu.cse.ClassMap.onCreate
06-12 22:58:39.340: WARN/dalvikvm(200): VFY: unable to resolve new-instance 21 (Lfau/edu/cse/TempConvert;) in Lfau/edu/cse/ClassMap;
06-12 22:58:39.340: DEBUG/dalvikvm(200): VFY: replacing opcode 0x22 at 0x0027
06-12 22:58:39.340: DEBUG/dalvikvm(200): Making a copy of Lfau/edu/cse/ClassMap;.onCreate code (252 bytes)
06-12 22:58:39.490: DEBUG/dalvikvm(30): GC freed 2 objects / 48 bytes in 273ms
06-12 22:58:39.530: DEBUG/ddm-heap(119): Got feature list request
06-12 22:58:39.620: WARN/Resources(200): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f050000}
06-12 22:58:39.620: WARN/System.err(200): java.lang.NoClassDefFoundError: fau.edu.cse.TempConvert
06-12 22:58:39.830: WARN/System.err(200):     at fau.edu.cse.ClassMap.onCreate(ClassMap.java:26)
06-12 22:58:39.830: WARN/System.err(200):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-12 22:58:39.830: WARN/System.err(200):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
06-12 22:58:39.830: WARN/System.err(200):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
06-12 22:58:39.830: WARN/System.err(200):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
06-12 22:58:39.880: WARN/System.err(200):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
06-12 22:58:39.880: WARN/System.err(200):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-12 22:58:39.880: WARN/System.err(200):     at android.os.Looper.loop(Looper.java:123)
06-12 22:58:39.880: WARN/System.err(200):     at android.app.ActivityThread.main(ActivityThread.java:4363)
06-12 22:58:39.880: WARN/System.err(200):     at java.lang.reflect.Method.invokeNative(Native Method)
06-12 22:58:39.880: WARN/System.err(200):     at java.lang.reflect.Method.invoke(Method.java:521)
06-12 22:58:39.880: WARN/System.err(200):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-12 22:58:39.880: WARN/System.err(200):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-12 22:58:39.880: WARN/System.err(200):     at dalvik.system.NativeStart.main(Native Method)

...bla...bla...bla

It would be great if someone just had an answer, however I am looking at debug strategies. I have taken this same application and created a standard java client application and it works fine -- of course with all of the android stuff taken out. What would be a good debug strategy? What methods and techniques would you recommend I try and isolate the problem? I am thinking that there is some sort of Dalvik VM incompatibility that is causing the TempConvert class not to load. TempConvert is an interface class that references a lot of very tricky webservice attributes. Any help with debug strategies would be gladly appreciated.

Thanks for the help, Steve


If your are using an external library, for example in case of external library of Goolge map you have to add

<uses-library android:name="com.google.android.maps" />

inside the <Application> tag in Android Manifest.xml


Here's your problem:

java.lang.NoClassDefFoundError: fau.edu.cse.TempConvert

From the javadocs:

Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

Sounds like you have an Android deployment or packaging issue. It can't find your class, despite your assumptions.

When you observe behavior that counters your assumptions, you should put them aside and check everything from the beginning. Assuming that everything is correct, in spite of the evidence you have before your eyes, gets in the way of finding a solution.


I resolved this by moving <uses-library android:name="com.google.android.maps" /> inside of the <application> tags in my AndroidManifest.xml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜