Ant 使用依赖库构建 Android 项目
我有两个 Android 项目,一个共享库和一个应用程序。现在我想编译依赖于库的应用程序。在 Eclipse 中,它运行得很好。之后,我通过 git 将其上传到我的存储库并触发 Jenkins 构建这两个项目。
我的问题是,出现错误:“sdk/android-sdk-linux/tools/ant/build.xml:440: ../shared-lib 解析为没有项目的 project.properties 文件的路径”。这很清楚,因为 Jenkins 中的作业存储方式与 Eclipse 中不同。
另一个问题是,Eclipse 将共享编译为“.jar”,而 Ant 将其编译为“classes.jar”(在 sdk/android-sdk-linux/tools/ant/build.xml 中命名)。
I have two Android projects, one shared library and the app. Now I want to compile the app with dependency to the library. In Eclipse, it works very well. After that, I upload it via git to my repository and trigger Jenkins to build both projects.
My problem is, that the error occurs: "sdk/android-sdk-linux/tools/ant/build.xml:440: ../shared-lib resolve to a path with no project.properties file for project". That's clear, because in Jenkins the jobs are stored different than under Eclipse.
Another problem is, that Eclipse compiled the shared to ".jar" and Ant compiled it to "classes.jar" (is named in sdk/android-sdk-linux/tools/ant/build.xml).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Ant 脚本应该允许您包含您需要的任何文件。在您的情况下,我建议您将对
shared-lib
的引用移至local.properties
文件(此文件也应该由 update-project 生成的 ant 脚本读取)在存储库中保留 jenkins 的适当路径并在本地修改文件以进行本地构建。在存储库中的文件中,您需要具有以下内容:编辑属性文件只是因为这个文件实际上是用来存储特定于位置的属性。
Ant scripts should allow you to include whatever files you need. In your case I will suggest you move the reference to the
shared-lib
tolocal.properties
file (this file should also be read by the ant script generated by update-project. Keep the adequate path for jenkins in the repository and modify the file locally for the local built. In the file in the repository you will need to have something like:EDIT By the way the suggestion of the second properties file is just because this file is really meant to store location-specific properties.
我用复制文件修复了它。第一个项目构建我的
shared-lib.jar
。其他项目(手机和平板电脑)将此文件(shared-lib.jar)复制到 libs 文件夹并正确构建。但现在我在服务器和开发客户端上有不同的projects.properties
。这个没有签入到 git 中。I fixed it with copy files. The first project builds my
shared-lib.jar
. The other projects (phone and tablet) copy this file (shared-lib.jar) to therelibs
-folder and build correctly. But now I have differentprojects.properties
on the server and my dev-client. This one is not checked in into git.