0

I am trying to use external jar file in android application. The jar file is running well in another java application but when I am trying to use the Jar file with Android Application by BuildPath-> Add External Jars; it is showing following errors

"could not find class referenced from method ".

Please help me out from this.

Thanks

Shorav

Kumar Shorav
  • 531
  • 4
  • 16
  • Possible duplicate of [How can I use external JARs in an Android project?](http://stackoverflow.com/questions/1334802/how-can-i-use-external-jars-in-an-android-project) – Yochai Timmer Oct 31 '15 at 07:52

2 Answers2

2

Maybe the ADK update has messed-up with your project's build-path. Try removing the JAR and add it again to your libs folder, and do a Clean Project.

following poster's comment about not having a libs folder:

You should try this:

Remove all references to the JAR in your project -> your code should not build without error anymore

Create à libs folder at the root of your project

Copy the JAR into the libs folder

(If still not running OK) Right click your project > Android Tools > Fix Project Propertie

RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166
  • I tried this but without success. Following errors are coming up - 07-04 17:52:03.802: E/dalvikvm(223): Could not find class 'org.AstroVed.Panchanga.Moment', referenced from method com.astroved.horawatch.HoraWatchActivity.onCreate Please explain your process once again because in ADT 20, libs folder are automatically created. I tried in both ways . By creating own libs folder and copying the jar file there as well as through importing external jar through Configure Build path. Thanks – Kumar Shorav Jul 04 '12 at 12:46
  • just copy jar file into the libs folder, no need to do more than that – RajaReddy PolamReddy Jul 04 '12 at 12:59
  • Still the same error is coming .....I removed my own created libs folder and then copied the jar file in automatically generated libs folder of the project---> clean the project and then Run but without success. Please have you any other solutions?????? thanks Shorav – Kumar Shorav Jul 05 '12 at 06:09
  • i solved this problem by using the above process when i was get. try to do step by step process you can get it.. – RajaReddy PolamReddy Jul 05 '12 at 06:36
  • Yes, I am trying to solve it as you said from start. Let me see. may i have your skype id...? – Kumar Shorav Jul 05 '12 at 06:41
  • If I am running jar file on cmd through command or in Java application it is running well and i am getting desired result. So I suppose that Jar is correct and there is no error in Jar file. Is it a versioning of ADT problems or jar problems?? could you please clarify ???? – Kumar Shorav Jul 05 '12 at 07:34
  • i think ADT problem, i was also faced same problem when i was updated my andorid SDK. – RajaReddy PolamReddy Jul 05 '12 at 08:42
  • yes.. i am also having the same conclusion but trying to get it run...thanks for your guidance – Kumar Shorav Jul 05 '12 at 09:10
  • http://stackoverflow.com/questions/8653619/include-jar-into-apk-with-eclipse I have compiled the Jar file in Java 1.7 version. Is there any problems with this ???? I have gone through the above link where I found jar should be built on Java 1.6?????Please help??? – Kumar Shorav Jul 05 '12 at 09:46
  • i sent the request as well in SKYPE. – Kumar Shorav Jul 05 '12 at 09:58
  • I posted the same question by copying LogCat. Please have a look for getting the correct ideas about the errors. I am just stuck with this. I tried same way as you said...the external jar is visible in Android dependecies as well as. but application is forced to close unexpectedely. Please help ... – Kumar Shorav Jul 06 '12 at 05:23
  • nothing working ....i am just struggling with this............... However the problem is at runtime not at compile time because When I am importing the same class ... it is visible and I am able to intialize the constructor for the same class without error...but at run time it is showing following error-- Could not find class 'org.AstroVed.Panchanga.Moment', referenced from method com.astroved.horawatch.HoraWatchActivity.onCreate 07-06 10:32:07.244: W/dalvikvm(319): Is it error related to class path?????? – Kumar Shorav Jul 06 '12 at 10:23
0

If you want to use a Jar in android application you may create it like this:

  1. Open your IDE
  2. Click on new
  3. Choose new Android project
  4. Give the name of your project
  5. Check option make this project as library
orique
  • 1,295
  • 1
  • 27
  • 36