I am trying to create a jar file for a java project and then reference the jar file in the android project. As a test, I create a simple java project containing only the following class
package test;
public class Test {
public static void hello(){
System.out.println();
}
public static void main(String[] args){
hello();
}
}
I am exporting this project executable jar file to Eclipse. Then I copy this jar file to the "libs" folder of the android project, so the jar file appears in the private library, and I check the private library field on the "Order and Export" tab. I reference the jar file by adding the following statement to onCreate () of the main action of the android project
Test.hello();
However, when I run the Android project, I get
java.lang.NoClassDefFoundError: test.Test
mistake. Full bug tracking track below
10-17 23:14:52.976: E/AndroidRuntime(16725): FATAL EXCEPTION: main
10-17 23:14:52.976: E/AndroidRuntime(16725): java.lang.NoClassDefFoundError: test.Test
10-17 23:14:52.976: E/AndroidRuntime(16725): at
com.skyhookwireless.samples.wpsapitest.WpsApiTest.onCreate(WpsApiTest.java:71)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
android.app.Activity.performCreate(Activity.java:4470)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
android.app.ActivityThread.access$600(ActivityThread.java:128)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
android.os.Handler.dispatchMessage(Handler.java:99)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
android.os.Looper.loop(Looper.java:137)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
android.app.ActivityThread.main(ActivityThread.java:4517)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
java.lang.reflect.Method.invokeNative(Native Method)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
java.lang.reflect.Method.invoke(Method.java:511)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
10-17 23:14:52.976: E/AndroidRuntime(16725): at
dalvik.system.NativeStart.main(Native Method)
"" "" , . 

- , ?
(, this) NoClassDefFoundError , . .