Ant rebuilding library projects every time

眉间皱痕 提交于 2019-12-03 07:59:06

Add dont.do.deps=1 to your local.properties (or pass this property to ant some other way)

yorkw

This is how Android Library Project is designed and suppose to work at the moment, it is always compiled indirectly along with the main application project compilation, see this 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.

... ...

Development considerations

  • You cannot export a library project to a JAR file

    A library cannot be distributed as a binary file (such as a JAR file). This will be added in a future version of the SDK Tools.

How can I avoid ant compiling the two Android library projects each build?

The thing you talking about is a pre-compiled jar file. There are some posts here suggest using Eclipse export function or the auto-generated jar under library project's bin directory, it may work in some simple case like the library project contains purely Java file, but will not work if the library project become more complicated which contains Android resource files. In this case, there are some dirty hack like this one which IMO cause more trouble than it solves.

Android dev team is working on it and try to change Android Library Project from source-based mechanism to compiled-code based library mechanism. more details in this blog post. I suggest waiting for the ultimate solution from official dev team.

mav

I had issues with slow Android compilation when I had libraries in my project and solved this by applying "--incremental" switch to dex tool. See this question on SO.

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