如何使用ant构建android

use*_*624 9 ant android

我想为我的项目设置一个ant build.我找到了一个教程,说我需要编写以下命令才能为ant build做准备:

android update project -p 
Run Code Online (Sandbox Code Playgroud)

然后我得到了结果

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.
Run Code Online (Sandbox Code Playgroud)

所以,如果我尝试

android update project -p . --subprojects
Run Code Online (Sandbox Code Playgroud)

然后我得到:

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.
Run Code Online (Sandbox Code Playgroud)

如果我试试

ant release
Run Code Online (Sandbox Code Playgroud)

我明白了

sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我用ant建立项目.谢谢

Aun*_*yae 15

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

android update project --path . --subprojects --target android-19
Run Code Online (Sandbox Code Playgroud)


ANT会自动将您的sdk.dir设置为正确的.
不要在local.properties中放置任何内容.

# 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.
Run Code Online (Sandbox Code Playgroud)