简体   繁体   中英

Shared jar files for Android project and library

I have an android application that is split in a Android library and a regular Android project. Using the new r14 SDK the library project compiles separately. My library and project uses an external jar file (joda-time), where do I put the jode-time jar file? If I put it in my library's libs folder AND my app's libs folder, I get a dex error saying class already added.

看看Android SDK工具中的文章项目变更,r14我想你可以找到答案

I had the same question. This is how I worked it out:

In the library project:
- copy the jar file to the /libs directory
- add the jar to the Build Path (right click on the jar, select Build Path, add to Build Path)
- export the jar to make it visible to dependant projects (right click on the jar, select Configure Build Path, tab Order and Export, check the jar)

In the dependant project:
- add the jar to the Build Path of the project (right click on the project, select Configure Build Path, tab Libraries, button "add JARs" and navigate to the jar file in the library project)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM