简体   繁体   中英

Adding a Java Library with External Dependencies to an Android Project

Let me start by saying my in-depth understanding of the Java application/Android application is far from complete and that the notion of .jars is still a hazy concept for me.

I'm currently trying to make use of an existing Java project for an Android project. This existing Java project has dependencies on two .jars.

My goal is to take this project, modify it (take out the main function, change some algorithms, etc) , and then use it as a library for my Android project to reference.

I've seen people exporting their Java projects as .jars and runnable .jars and then adding the jars to their Android projects - however this doesn't work out for me. It either complains about my build-path (solved by adding the Java project's two .jars) or crashes Eclipse.

I'd prefer not to use plugins/third party programs or have three separate .jars (one from the Java project, two from the Java project's requirements).

Could someone explain the idea behind building a Java project as a library with external dependencies, and how that can be used as one .jar in an Android application?

Thanks!

You may be making mistake in creating jar file. Some time it get exported properly but will throw error at runtime. While exporting project, don't forget to remove .project and .classpath option.

Go to project explorer> Right Click on your project> Export.

You can follow below blog for more information on creating libraries. Please look at step 4 of "Enhancing library feature" Tutorial: How to create java library

Please let me know if does not work out.

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