9

I tried a couple of different ways but failed. Can you share what the right way is to tell intelliJ to include a jar file in the libs directory?

Thanks

BraveNewMath
  • 8,090
  • 5
  • 46
  • 51

3 Answers3

16

In the Project Structure | Modules | Dependencies add the new library and use Jar Directories type of the entry for the lib directory. Now all the jars from the lib directory will be available for the project and will be packaged automatically into the final .apk file.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • It works. Thanks. I think the problem was two-fold. First is I wasn't sure of how to add dependencies, which your answer solved. And 2, I needed to get rid of some jar files. I come from an Eclipse background, and Eclipse lets you add references to jar files one at a time. So I had two versions of the same jar file in the libs directory. After removing one, the project compiled successfuly – BraveNewMath Jan 18 '11 at 08:17
1

Unfortunately, Intellij 10.0.2 has a GUI for File/ProjectStructure/Modules/Dependencies with an internal, un-resizeable text box. Thus, buttons for the panel are off screen even if you have (imho!) a normal size computer... (Normal is always relative to oneself!) The only way to find them is to push and pull and prod the window around. Then these instructions all make perfect sense.

AnneTheAgile
  • 9,932
  • 6
  • 52
  • 48
0

I assume you added the libraries on Module Settings >> Modules >> Dependencies.

When you add the library and the Export check box is selected, then the library is packaged with the final deployable. Also make sure that the scope is not "provided" (scope is similar to maven dependency scope).

Let me know if it does not work.. Will be glad to help.

uncaught_exceptions
  • 21,712
  • 4
  • 41
  • 48
  • Export checkbox has nothing to do with packaging and is not needed in this case. – CrazyCoder Jan 17 '11 at 14:02
  • Hmmm. I might be wrong. I will check it anyways. Thanks for the correction. The following is an excerpt from intellij documentation. "Export If this option is checked, the dependency is exported to the modules that depend on the current one.". I have a practice of using it If I want the module's jar file available for a parent module. Hence the assumptions its packaged with the artifact. – uncaught_exceptions Jan 17 '11 at 14:35