Replace Android library project by JAR library?

匆匆过客 提交于 2019-12-14 00:40:18

问题


In my project, there are many library project (more than 10). It takes long time to build. So I want to replace some of these library projects by JAR libraries.

According to this question: How to Convert an Android Library Project to an External JAR?

As CommonsWare's answer (https://stackoverflow.com/a/7973950/190309)

If your library is purely Java code, with no resources, you can create a JAR out of the .class files, just as you would with regular Java.

But when using NineOldAndroids library (https://github.com/JakeWharton/NineOldAndroids) from Jake Wharton,

This library is presented as a .jar file which you can include in the libs/ folder of your application.

It means although there are many resources in NineOldAndroids, I can use it as a JAR library instead.

With ADT 17, for every library project, there is a JAR library in lib_project/bin/lib_project.jar which automatically generated each time library project is built.

Can I use this JAR as an alternative for library project?


回答1:


It means although there are many resources in NineOldAndroids

There are precisely zero resources in NineOldAndroids. You can tell this by looking at the project and seeing that there is no res/ directory.

With ADT 17, for every library project, there is a JAR library in lib_project/bin/lib_project.jar which automatically generated each time library project is built.

Can I use this JAR as an alternative for library project?

Not at this time. That JAR still depends on the library project itself.




回答2:


I have tried and documented this issue in how-to-consume-reusable-gui-element-widget-with-resources-in-android and i didn-t succeed with adt-17. but maybe i did something wrong.

CommonsWare-s answer to my qestion says

 > Eventually (which now appears like it will be the R18 version of tools or later), the 
 > tools should support packaging reusable components in a JAR, with resources, in 
 > such a manner that you can add them to a host project and the resources will 
 > be blended in automatically. Right now, that's not an option.



回答3:


If you look into the jar generated for a library project, you'll see there is no resource in it. It is only used for the Java classes.



来源:https://stackoverflow.com/questions/10176519/replace-android-library-project-by-jar-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!