Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How export jars from library project to referencing projects in Eclipse?

Several Android projects use a Android library project. Now I added a JAR (commons-lang.jar) to this library project. I want to export this commons-lang.jar to all projects that use the library project. I can't get it to work without duplicating the jar to all referencing projects.

What I did so far:

  1. Created a folder named libs within the library projects folder hierarchy.
  2. Copied the JAR to this libs folder.
  3. Added this JAR in the Eclipse "Java Build Path" with "Add external JARs..." to the library project.
  4. On the "Order and Export" tab selected the checkbox to the left of the JAR to export it.
  5. On the referencing project on the "Android" page "Add" library project.

It seems that the commans-lang JAR is not exported with the library project. I need to create the libs folder on the referencing project as well, add the same JARs to the build path of the referencing project. After that everything works but the APK does contain that external JAR twice.

What's wrong with my approach? What should I do in addition?

Many thanks in advance.

like image 293
Harald Wilhelm Avatar asked Jul 18 '11 08:07

Harald Wilhelm


1 Answers

I believe that what you do is go to Eclipse > preferences > Java > Build Path > User Libraries. Then when you add a jar file to that I believe that all of the projects in the workspace automatically have that jar in the classpath.

like image 132
Aidan Avatar answered Oct 24 '22 17:10

Aidan