如何聪明就是Eclipse / ADT,当涉及到Android库项目? [英] How smart is Eclipse / ADT when it comes to Android Library Projects?

查看:114
本文介绍了如何聪明就是Eclipse / ADT,当涉及到Android库项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有一把工具样式类在我的一些项目。我很好奇,如果我可以将它们移到一个Android库项目,其中包含的全部或大部分我的非应用程序专用胶水code(包装和接口,多)。

So, I've got a handful of "Utility" style classes in some of my projects. I'm curious if I can move them to an Android Library Project that contains all or most of my non-app specific glue code (wrappers and interfaces, mostly).

所以,我的问题是发生在我不需要该库中的文件内容。我知道的Andr​​oid库项目基本上就是复制他们的code到其他项目,所以如果我说在我的通用库中使用的code的25%,将我的应用程序实际上包含字节code所有的100%,或者它正确地剥离下来,只有我需要的东西。

So, my question is what happens to the files I don't need in that library. I know Android Library Projects basically just copy their code into the other project, so if I say use 25% of the code in my "general purpose" library, will my app actually contain the bytecode for all 100%, or does it properly strip it down to only the stuff I need.

我有未使用的类Proguard的过去的一些问题,所以我只是曾经被蛇咬,十年怕井绳与ADT现在...

I had some issues with unused classes in Proguard in the past, so I'm just once-bitten, twice shy with the ADT now...

推荐答案

不幸的是,所有的项目将在该库是挺大增长 - 即使该库的大部分内容不被使用。我测试了它自己创建一个应用程序A和一个图书馆L.如果L是用一个函数库,classes.dex文件(并因此A.apk文件)越来越大,如果我添加更多的类 - 即使他们不用了。

Unfortunately, all your projects will grow when the library is getting bigger - even if most contents of that library are not used. I tested it myself by creating an app A and a library L. If L is a library used in A, the classes.dex file (and therefore the A.apk file) is growing if I add more classes - even if they are not used.

要总结一下:现在我会为某些事情是小,可用于许多项目基本库,并创建该将是更大的每一个新组件创建新库,并仅使用一些项目。一个很好的候选人,一个新的图书馆将与在资源定义的多个图像的新UI组件。一个很好的候选人基本库是常用的方法之类的文件缓存,例如。编译code是COM pressed相当严重的Dalvik的,你可以看到的这里(整个presentation实际上是让人赏心悦目: - )

To sum up: Right now I would create a basic library for certain things that are small and that may be used by many projects, and create a new library for every new component that is going to be larger and only is used by some projects. A good candidate for a new library would be a new UI component with multiple images defined in the resources. A good candidate for the base library are commonly-used methods and things like file caches, for example. Compiled code is compressed quite heavily for Dalvik, which you can see here. (The whole presentation is actually fun to watch :-)

编辑:如果ProGuard的被激活,它还会删除未使用的code为您服务。默认proguard.cfg就足够了。它不会对建(默认)调试运行,但最终的.apk文件编译时。因此,它实际上是可能的!

If ProGuard is activated, it will also remove unused code for you. The default proguard.cfg is sufficient. It will not run on the (default) debug built, but when the final .apk is compiled. So it actually is possible!

这篇关于如何聪明就是Eclipse / ADT,当涉及到Android库项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆