将大型Android项目切成Android库是否会缩短构建时间?

将大型Android项目切成Android库是否会缩短构建时间?,第1张

概述我有一个相当大的Android项目,并且sdk需要花费大量时间来进行资源解析/dexing/etc等工作.我想以某种方式进行改进.我读过,Android库项目现在也可以包含资源.因此,我们也可以将“活动”,“片段”等放入其中.这是否意味着,如果我将大型项目的一部分导出到从主项目引用的库项目中

我有一个相当大的Android项目,并且sdk需要花费大量时间来进行资源解析/ dexing / etc等工作.我想以某种方式进行改进.

我读过,AndroID库项目现在也可以包含资源.因此,我们也可以将“活动”,“片段”等放入其中.

这是否意味着,如果我将大型项目的一部分导出到从主项目引用的库项目中,那么在重建主项目时,我不必再次重建已构建(但未修改)的库?因此,我只需要对修改后的库以及可能的主项目进行资源解析/分解/等 *** 作,就可以减少大多数情况下的总体构建时间.

解决方法:

Does this mean, that if I export parts of my large project into library projects which I reference from the main project, then I don’t have to rebuild the already built (and not modifIEd) librarIEs again, when I rebuild the main project?

部分没有,AndroID library Project不是直接构建的,它总是与依赖的Main Project一起构建的,当SDK编译/构建Main Project时,SDK工具会将library Project编译为一个临时JAR文件,并在主项目中使用它.每当您重建主项目时,参考的图书馆项目都会作为主项目构建生命周期的一部分进行重建,即使图书馆项目中没有任何更改.查看在app-lib / bin文件夹下生成的临时JAR的时间戳以获取证据,每次构建Main Project时,它总是会更改.

从official dev guide报价:

However, a library project differs from an standard AndroID application project in that you cannot compile it directly to its own .apk and run it on an AndroID device. Similarly, you cannot export the library project to a self-contained JAR file, as you would do for a true library. Instead, you must compile the library indirectly, by referencing the library in the dependent application and building that application.

When you build an application that depends on a library project, the SDK tools compile the library into a temporary JAR file and uses it in the main project, then uses the result to generate the .apk. In cases where a resource ID is defined in both the application and the library, the tools ensure that the resource declared in the application gets priority and that the resource in the library project is not compiled into the application .apk. This gives your application the flexibility to either use or redefine any resource behaviors or values that are defined in any library.

AndroID library Project与常规的Java库项目不同.您可以在其中一次将所有内容编译并构建到jar库中,并从主项目中的参考jar依赖项开始导入/使用该类.当前AndroID库项目是基于this Android blog中提到的基于源的机制而不是基于编译代码的库机制设计的,尽管在将来的版本中承诺自包含的jar发行版(不幸的是,尚未在r15,r16,r17或r18中都没有) .

总结

以上是内存溢出为你收集整理的将大型Android项目切成Android库是否会缩短构建时间?全部内容,希望文章能够帮你解决将大型Android项目切成Android库是否会缩短构建时间?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1085520.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存