ant debug和sdk.dir

lor*_*bik 8 ant android cocos2d-x

我在生成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
Run Code Online (Sandbox Code Playgroud)

我不知道是什么问题.

Com*_*are 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
Run Code Online (Sandbox Code Playgroud)

要创建此文件(如果该文件不存在),请运行android update project -p ......项目的路径.

  • 好的,用这种语法解决:ant -Dsdk.dir = $ ANDROID_HOME -Dtarget = android-16 debug.无论如何,谢谢你的帮助! (5认同)

Lyo*_*eel 13

我有同样的问题,我使用-Dvar或VM参数解决问题.

ant debug -Dsdk.dir=$SDK_ROOT
Run Code Online (Sandbox Code Playgroud)

其中$ SDK_ROOT是android SDK路径