Ant debug and sdk.dir

I am having trouble creating an APK file for Android.

When I run ant debug , compilation works fine, but when I run ant debug

I have the following error:

 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 

I do not know what the problem is.

+8
android ant cocos2d-x
source share
2 answers

Your project should have a local.properties file with the sdk.dir line that indicates where your Android SDK is installed:

 # 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 

To create this file if it does not exist, run android update project -p ... , where ... is the path to your project.

+17
source share

I had the same problem, I solve the problem using the -Dvar or VM argument.

 ant debug -Dsdk.dir=$SDK_ROOT 

where $ SDK_ROOT is the path to the Android SDK.

+13
source share

All Articles