[英]Building Android projects that reference library projects with ANT
After updating my sdk tools I cannot build my project from the command line. 更新我的sdk工具后,我无法从命令行构建我的项目。
I have been using the steps on the Managing Projects from the Command Line on the Android Developers site to build using ANT. 我一直在使用Android开发者网站上命令行管理项目的步骤来使用ANT进行构建。 My project references another library project, so I've been using:
我的项目引用了另一个库项目,所以我一直在使用:
android update lib-project --target <target_ID>
--path path/to/your/project
--library path/to/library_projectA
to update my default.properties
, local.properties
and build.xml
files, and ant.bat build.xml
to build the .apk
. 更新我的
default.properties
, local.properties
和build.xml
文件,以及ant.bat build.xml
来构建.apk
。 This has worked without any problems for some time. 这在一段时间内没有任何问题。
Recently I updated my sdk tools to rev 10, platform-tools rev 3. The first thing I ran into is that it seems the --library
flag is missing. 最近我将我的sdk工具更新为rev 10,platform-tools rev 3.我遇到的第一件事是似乎缺少
--library
标志。 I noticed the 'update project' now has a --library
option, so I assume I should be using that command now to update projects that reference libraries. 我注意到'更新项目'现在有一个
--library
选项,所以我假设我现在应该使用该命令来更新引用库的项目。
Problem is that although the default.properties
, local.properties
and build.xml
files all look good for the library and the application, running ant.bat build.xml
on the app that references the library project now fails with "Failed to resolve library path" followed by the path it is trying to resolve, which is indeed the right path. 问题是虽然
default.properties
, local.properties
和build.xml
文件对于库和应用程序ant.bat build.xml
,但是在引用库项目的应用程序上运行ant.bat build.xml
现在失败并显示“无法解析库”路径“后面是它试图解决的路径,这确实是正确的道路。
Even if I don't use 'update project' and revert to the default.properties
, local.properties
and build.xml
files that used to work for ant.bat build.xml
, it still fails with this same error since the sdk update. 即使我不使用'更新项目'并恢复到
local.properties
用于ant.bat build.xml
的default.properties
, local.properties
和build.xml
文件,它仍然会因为sdk更新而失败并出现同样的错误。
Any advice would be greatly appreciated. 任何建议将不胜感激。 Thanks!
谢谢! Scott
斯科特
I found a solution to that: 我找到了一个解决方案:
When making the instruction of adding to library folder, try to do it with a relative path like this: 在发出添加到库文件夹的指令时,尝试使用这样的相对路径:
android update project --target 3 --path c:/Absolute/Path/Of/Project --library ../actionbar(relativePathOfLibrary)
android更新项目--target 3 --path c:/ Absolute / Path / Of / Project --library ../actionbar(relativePathOfLibrary)
I found the same problem as you, but by this way it worked fine. 我发现了和你一样的问题,但通过这种方式它运行良好。
I think the command may have moved from lib-project to project. 我认为命令可能已经从lib-project转移到了project。 Try the following instead.
请尝试以下方法。
android update project --path path/to/your/project --library path/to/library_projectA
The example you gave omitted the target number. 您给出的示例省略了目标编号。 You can also update the target if you provide a valid target number.
如果您提供有效的目标号码,也可以更新目标。 As you probably already know, you can see a list of valid targets using the following command.
您可能已经知道,您可以使用以下命令查看有效目标列表。
android list targets
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.