If you create a Java project, how do you use classes that are only in Android but not regular Java?
(like *android.graphics.Canvas*) On Friday, September 21, 2012 1:44:06 PM UTC-5, Dalvin wrote: > > Better approach is to create java project instead of android project if > you want to create jar. If you want to have a common android code for > multiple projects then go for android library project. > > ... > Singh > > On Fri, Sep 21, 2012 at 11:45 PM, bob <b...@coolfone.comze.com<javascript:> > > wrote: > >> Ok. I created a "libs" folder. >> >> >> I drag-and-dropped the jar into it. >> >> >> I did an "Add JARs…". >> >> >> It didn't like that I had AndroidManifest.xml and an icon in the JAR, so >> I fiddled around till I pulled >> >> that stuff out. >> >> >> Then, it worked. >> >> >> Thanks. >> >> >> >> >> On Friday, September 21, 2012 10:56:17 AM UTC-5, Jay Howard wrote: >>> >>> Guessing you need to have it in the lib directory in your Android >>> project. Adding it as an external library in eclipse adds it to your >>> eclipse classpath, so the build errors disappear in eclipse, but the >>> android build process only packages the jars it finds in your project's lib >>> dir. >>> >>> On Friday, September 21, 2012 10:41:42 AM UTC-5, bob wrote: >>>> >>>> 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-d...@googlegroups.com<javascript:> >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- 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