我在生成Android APK文件时遇到问题。
当我运行ant debug
编译工作正常时,但是当我运行ant debug
我有以下错误:
iMac:proj.android smartmind$ ant debug
Buildfile: /Users/smartmind/Works/Smallthing/cocos2d-x/samples/HelloCpp/proj.android/build.xml
BUILD FAILED
/Users/smartmind/Works/Smallthing/cocos2d-x/samples/HelloCpp/proj.android/build.xml:46: sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var
Total time: 0 seconds
我不知道什么是问题。
答案 0 :(得分:17)
您的项目应该有一个local.properties
文件,其中sdk.dir
行指向Android SDK的安装位置:
# 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.
sdk.dir=/opt/android-sdk-linux_x86
要创建此文件(如果该文件不存在),请运行android update project -p ...
,其中...
是项目的路径。
答案 1 :(得分:13)
我遇到了同样的问题,我使用-Dvar或VM参数解决了这个问题。
ant debug -Dsdk.dir=$SDK_ROOT
其中$ SDK_ROOT是android SDK路径