9

我在生成 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

我不知道有什么问题。

4

2 回答 2

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 ...所在的位置运行。...

于 2012-11-09T17:37:15.480 回答
14

我有同样的问题,我使用 -Dvar 或 VM 参数解决了这个问题。

ant debug -Dsdk.dir=$SDK_ROOT

其中 $SDK_ROOT 是 android SDK 路径

于 2013-04-21T16:59:12.123 回答