2013-04-25 63 views
9

我想为我的项目建立一个ant build。我发现了一个教程说,我需要的,以便为Ant构建准备写下面的命令:如何使用ant来搭建android

android update project -p 

然后我得到的结果

Updated local.properties 
Updated file ./proguard-project.txt 
It seems that there are sub-projects. If you want to update them 
please use the --subprojects parameter. 

所以如果我尝试

android update project -p . --subprojects 

然后我得到:

Updated local.properties 
Updated file ./proguard-project.txt 
Error: The project either has no target set or the target is invalid. 
Please provide a --target to the 'android update' command. 

如果我尝试

ant release 

我得到

sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var 

有人可以帮我设置了蚂蚁的项目。 谢谢

回答

14

我也有同样的问题。
我的问题问题已通过以下命令解决。

android update project --path . --subprojects --target android-19 


ANT将自动为您sdk.dir到正确的。
不要在您的地方放置任何东西。属性。

# This file is automatically generated by Android Tools. 
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! 
# 
# This file must *NOT* be checked into Version Control Systems, 
# as it contains information specific to your local configuration. 

# location of the SDK. This is only used by Ant 
# For customization when using a Version Control System, please read the 
# header note. 
+1

目标应该指定为:'--target android-19'。 – 2014-09-16 12:41:32

0

请务必在您的项目(主项目和库)中设置目标。

在Eclipse上: 右键单击项目 - >属性 - > Android并选择您的目标SDK。这意味着您定位的Android SDK版本。如果你把在manifest.xml一看,你会看到,几乎在一开始:

<uses-sdk 
    android:minSdkVersion="9" 
    android:targetSdkVersion="17" /> 

这是你的项目目标版本,通常建议为最高(最新)尽可能是。

之后,要确保该文件project.properties有类似这样的一行:

target=Google Inc.:Google APIs:17 

该文件将由ANT被看了就知道了项目的目标。您可以手动添加该行。其实,我敢肯定,它会自动如果您设置在Eclipse项目的目标运行android update project -p . --subprojects

关于这个错误之前被列入(正如我上面说的):

sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var 

这意味着你没不定义sdk.dir属性,它应该指向文件系统中的android sdk根目录。在运行android update project -p . --subprojects之后,它应该为您的所有项目自动生成。这可能不是由于以前的错误。因此,检查所有的项目名为local.properties文件,并确保包含类似这样的一行:

sdk.dir=/home/path/to/android/sdk/android-sdk-linux 
+0

我有我的project.properties有一行:目标=机器人-18,也有类似于你在manifest.xml文件描述什么东西,但是我收到了同样的信息作为OP。 “看起来有子项目,如果你想更新它们,请使用--subprojects参数。” – neodymium 2014-02-19 08:21:58