Eventually, I want to create a JAR library with my Android routines in it.

So, I tried this test:

package com.jar_test;

public class Jar_Test {
 public static void jar_test()
{
System.out.println("This is a JAR test");
}

}


I exported that to a JAR.




Then, I made this test app:

package com.jar_test2;

import com.jar_test.Jar_Test;

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

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Jar_Test.jar_test();
    }
}

However, I got this error when I ran it.


09-21 10:33:57.710: E/AndroidRuntime(3366): FATAL EXCEPTION: main
09-21 10:33:57.710: E/AndroidRuntime(3366): java.lang.NoClassDefFoundError: 
com.jar_test.Jar_Test
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
com.jar_test2.MainActivity.onCreate(MainActivity.java:14)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
android.app.Activity.performCreate(Activity.java:4469)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
android.app.ActivityThread.access$600(ActivityThread.java:127)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
android.os.Handler.dispatchMessage(Handler.java:99)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
android.os.Looper.loop(Looper.java:137)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
android.app.ActivityThread.main(ActivityThread.java:4507)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
java.lang.reflect.Method.invokeNative(Native Method)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
java.lang.reflect.Method.invoke(Method.java:511)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
09-21 10:33:57.710: E/AndroidRuntime(3366): at 
dalvik.system.NativeStart.main(Native Method)

Anyone know what's wrong?

I added the jar using 'Add External JARs…'

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to