简体   繁体   English

如何在Java项目中使用android库

[英]how to use android libraries in java project

I want to include android libraries in my java project. 我想在我的Java项目中包含android库。 Actually, I need to run android code in java environment , obviously, this android code would not contain any GUI based action, it will simply use android's predefined libraries ... please suggest to me how android's libraries can be included in java project. 实际上,我需要在java环境中运行android代码,显然,此android代码不会包含任何基于GUI的操作,它将仅使用android的预定义库...请向我建议android的库如何包含在java项目中。 Thanks in Advance ! 提前致谢 !

Find the JAR file containing the libraries you want to use, and add them to the Java project's build classpath. 查找包含要使用的库的JAR文件,然后将它们添加到Java项目的构建类路径中。

However this may not work, depending on the Android classes you want to use. 但是,这可能不起作用,具体取决于您要使用的Android类。 Some Android classes will have dependencies on the Android platform which will make it unlikely they will work ... or even load ... on a regular Java platform. 一些Android类将依赖于Android平台,这将使其不太可能在常规Java平台上运行甚至加载。

  • If you want to reference a java jar as reference: Add that to libs folder in you project Right click on project -> Properties - > java Build path -> libraries -> add jars 如果要引用Java jar作为参考:将其添加到项目中的libs文件夹中右键单击项目->属性-> Java构建路径->库->添加jars

  • If you want reference a android library project then Right click on project -> Properties - > Android - > Add (in lower part of window) 如果要引用一个android库项目,请右键单击项目->属性-> Android->添加(在窗口的下部)

You can use android apis in android library project 您可以在android库项目中使用android api

Setting up library project refer . 设置库项目参考

You can find the difference between jar library and android library here 您可以在此处找到jar库和android库之间的区别

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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