【问题标题】:ant debug, and sdk.dirant 调试和 sdk.dir
【发布时间】:2012-11-09 16:08:27
【问题描述】:

我无法生成 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

我不知道是什么问题。

【问题讨论】:

    标签: android ant cocos2d-x


    【解决方案1】:

    您的项目应该有一个 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 ...,其中 ... 是您的项目的路径。

    【讨论】:

    • 是的,我用“android update project -t android-16 -p”创建了这个文件。#这个文件是由 Android 工具自动生成的。#不要修改这个文件——你的更改将被删除! # # 此文件必须检入版本控制系统,# 因为它包含特定于本地配置的信息。 # SDK 的位置。这仅由 Ant 使用 # 用于在使用版本控制系统,请阅读#header note.sdk.dir=/Users/smartmind/Works/SDK/Android/sdk
    • BUILD FAILED /Users/smartmind/Works/SDK/Android/sdk/tools/ant/build.xml:569:执行此行时出现以下错误:/Users/smartmind/Works/Smallthing /cocos2d-x/cocos2dx/platform/android/java/build.xml:46: sdk.dir 丢失。确保使用 'android update project' 生成 local.properties 或通过 env var 注入它
    • @lordubik:除了确保您使用的是最新版本的 Android 工具,并确保 sdk.dir 的值确实正确之外,我没有任何建议。
    • android 工具使用 AVD 管理器进行更新,并且 sdk.dir 设置为 Android SDK 根目录。 (/Works/Android/sdk)
    • 好的,使用以下语法解决:ant -Dsdk.dir=$ANDROID_HOME -Dtarget=android-16 debug。无论如何感谢您的帮助!
    【解决方案2】:

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

    ant debug -Dsdk.dir=$SDK_ROOT
    

    $SDK_ROOT 是 android SDK 路径

    【讨论】:

    • 解决了我的问题!感谢您的回答。
    猜你喜欢
    • 2015-08-28
    • 2012-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-03
    • 2013-03-01
    • 2013-03-14
    • 2012-08-07
    相关资源
    最近更新 更多