简体   繁体   English

Android:可以制作包含其他库的库

[英]Android: Is is possible to make a lib jar that includes other libs

I have an android project that compiles to library jar for other applications to use. 我有一个android项目,可以编译到库jar中供其他应用程序使用。 I want to add some functionality that comes from a 3rd party library. 我想添加一些来自第三方库的功能。 I also want users of my library to only have to include one jar (mine). 我还希望图书馆的用户只需要装一个罐子(我的罐子)。

Is it possible to pack the 3rd party lib jar as part of mine? 是否可以将第3方lib jar打包为我的一部分?

If you design an Android application and specify it as an AndroidLibrary to construct your own jar with later, then all you have to do is include the jar in your build path. 如果您设计一个Android应用程序并将其指定为AndroidLibrary以便以后使用它来构建自己的jar,那么您要做的就是将jar包含在构建路径中。 When you export your jar for Android later, it will include the jars that you have been using inside your library. 稍后将jar导出为Android时,它将包括您在库中一直使用的jar。

If you want to make those calls public from the 3rd party jar, then I'm not sure off the top of my head if you would be able to use those public calls from just your lib. 如果您想通过3rd party jar公开这些电话,那么我不确定是否可以使用您的lib中的那些公开电话。 But I don't see why not. 但是我不明白为什么不这样。

You cannot reference jars inside of jars. 您不能在罐子内部引用罐子。 (well there might be some ways, but I don't think you want to do them) See here . (嗯,也许有一些方法,但我认为您不想这样做)请参见此处

If you link to an Android project you can reference the jars in that project. 如果链接到Android项目,则可以引用该项目中的jar。 If your library android project is exported to a jar, and if you want to use the inner jar's public API, then you have to include it separately. 如果您的库android项目已导出到jar,并且要使用内部jar的公共API,则必须单独包含它。

当用户将lib声明为依赖项时,使用Mavenpom.xml文件中定义libs依赖项,他们将获得所需的一切。

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

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