Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SDK.DIR丢失了吗?android更新项目?_Android_Ant - Fatal编程技术网

SDK.DIR丢失了吗?android更新项目?

SDK.DIR丢失了吗?android更新项目?,android,ant,Android,Ant,当我这样做的时候,我得到了这个错误 $ ant release sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var 在android更新项目中键入时,我遇到另一个错误,即我必须指定路径。。。。对该项目的支持 然后我尝试将cd放入我的项目目录中并执行以下操作 android update -p . a

当我这样做的时候,我得到了这个错误

$ ant release
sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var
在android更新项目中键入时,我遇到另一个错误,即我必须指定路径。。。。对该项目的支持

然后我尝试将cd放入我的项目目录中并执行以下操作

android update -p .
android update -path . 
etc,它说
-p
-path
不是全球公认的


有人能告诉我确切的语法吗?

您可以使用projet.properties文件中的
sdk.dir
来定义sdk主页或使用环境变量(对于团队工作更灵活)

导出ANDROID\u主页=

cd到项目目录并执行以下操作:单词project是命令的一部分,不能替换为实际的项目名称。文件中没有明确说明这一点,应加以改进

   android update project -p .

您可以使用命令行参数设置sdk.dir,例如:

ant -f xyz/build.xml clean release -Dsdk.dir=/Applications/adt-bundle-mac/sdk/

您可以使用以下
ant
命令将
ANDROID\u HOME
环境变量注入
sdk.dir
属性

$ ant debug -Dsdk.dir=$ANDROID_HOME

ANDROID_HOME
必须是一个绝对路径,例如
/Users/jameswald/Development/ANDROID sdk macosx
必须在正确的上下文中设置ANDROID_HOME,只需在bashrc上设置它,并不意味着在单击图标启动时设置了var(然后不会执行bashrc-但在检查控制台上是否设置了env var时,它会被执行)

您也可以将其放在studio.sh中:

#!/bin/sh                                                                                                                               
#                                                                                                                                       
# ---------------------------------------------------------------------                                                                 
# Android Studio startup script.                                                                                                        
# ---------------------------------------------------------------------                                                                 
#                                                                                                                                       

export ANDROID_HOME=/home/ligi/bin/android-sdk/

message()
{

这将从ant创建/修复local.properties:

android更新项目--名称--目标 --路径

名称参数是可选的

target是api版本

更多信息请点击这里

我也遇到了同样的问题,结果发现一个ant脚本出于某种原因引用了硬编码路径到
C:\ant
,而我的ant在
C:\apache ant-{version}
中找不到它。重命名ant目录后,一切正常

作为参考,我发现这个问题的文件是
\apacheant-{version}\bin\ant.bat
:第106行


编辑:我使用的是windows 8

我也遇到了同样的问题。在反复使用命令行命令几分钟后,我直接编辑了
本地.properties
文件

您的数据库中应该有一个名为local.properties的文件

<app-directory>\platforms\android
\platforms\android
文件夹。如果您没有文件夹,则可以创建它

文件中应该有一个引用,指定ant可以在何处找到您的android sdk。它应该如下所示:

sdk.dir=C:\\<path-to-sdk>\\sdk
sdk.dir=C:\\\\sdk
只需更新您的详细信息,将其指向正确的android sdk文件夹

双\出现在我的文件中。不确定原因,但似乎有效。:)


注意:此文件还需要复制到您的
CordovaLib
文件夹中,这是一个更深的文件夹:
\platforms\android\CordovaLib
是的,这些解决方案都不适合我。从这里开始:

打开终端窗口并输入以下内容(我希望这是sdk的完整路径):

导出ANDROID_HOME=/Applications/ADT/sdk 一旦有了这个集合,就需要将它添加到PATH环境变量中


导出路径=$PATH:$ANDROID_HOME/bin

ANDROID更新项目-p.
可能会解决您的问题。有时候,一旦执行了
android update project-p.
,您可能会得到这样一个O/p

Updated local.properties
----------
build.xml: Failed to find version-tag string. File must be updated.
In order to not erase potential customizations, the file will not be automatically regenerated.
If no changes have been made to the file, delete it manually and run the command again.
If you have made customizations to the build process, the file must be manually updated.
It is recommended to:
    * Copy current file to a safe location.
    * Delete original file.
    * Run command again to generate a new file.
    * Port customizations to the new file, by looking at the new rules file
      located at <SDK>/tools/ant/build.xml
    * Update file to contain
          version-tag: custom
      to prevent file from being rewritten automatically by the SDK tools.
----------
Updated file ./proguard-project.txt
It seems that there are sub-projects. If you want to update them
please use the --subprojects parameter.
更新的local.properties
----------
build.xml:找不到版本标记字符串。文件必须更新。
为了不删除潜在的自定义项,将不会自动重新生成文件。
如果未对文件进行任何更改,请手动删除该文件,然后再次运行该命令。
如果对生成过程进行了自定义,则必须手动更新该文件。
建议:
*将当前文件复制到安全位置。
*删除原始文件。
*再次运行命令以生成新文件。
*通过查看新规则文件,将自定义项移植到新文件
位于/tools/ant/build.xml
*更新要包含的文件
版本标签:自定义
防止SDK工具自动重写文件。
----------
更新文件。/proguard-project.txt
似乎有子项目。如果你想更新它们
请使用--subprojects参数。

如果是这样的话,试试这个命令
android更新项目-p-s

设置环境变量“ANDROID\u HOME”没有帮助。这可能是需要设置的另一个变量。我在Linux上,使用的是最新版本的SDK(r21)。您使用的是什么版本的SDK?我不能确切说明我使用的是什么设置,因为我相信SDK 16,它仍然可以在我使用的所有计算机和我设置的所有continuous integration server上工作。真的是obselete吗?这个命令应该是
android update project-p.
。这在Ubuntu上对我有效。@Rodja读取命令给出的错误消息。我刚刚从git hub签出了一个项目,上面的命令说“请为‘android update’命令提供一个--target。”如果你这样做,android update项目会很顺利如果你有子项目(例如facebook sdk),那么,“$android update project-s-t”android-19“-p”,用所需的target替换android-19。试过了,请注意,有一个奇怪的地方。。。如果路径不是以
/
开头,它将被附加到android\u根目录(如果您有env var)。我尝试了
-Dsdk.dir=~/android/sdk
,结果它看到了
/some/dir/~/android/sdk
。。。所以使用
-Dsdk.dir=/home/you/android/sdk
谢谢gcb,我在答案中添加了这个细节。这主要是shell的属性;~仅在单词开头扩展。它对我有效。虽然我已经在我的环境中定义了ANDROID_HOME,但是如果我只使用“ant debug”,它永远不会正常工作,直到我使用“ant debug-Dsdk.dir=$ANDROID_H”
Updated local.properties
----------
build.xml: Failed to find version-tag string. File must be updated.
In order to not erase potential customizations, the file will not be automatically regenerated.
If no changes have been made to the file, delete it manually and run the command again.
If you have made customizations to the build process, the file must be manually updated.
It is recommended to:
    * Copy current file to a safe location.
    * Delete original file.
    * Run command again to generate a new file.
    * Port customizations to the new file, by looking at the new rules file
      located at <SDK>/tools/ant/build.xml
    * Update file to contain
          version-tag: custom
      to prevent file from being rewritten automatically by the SDK tools.
----------
Updated file ./proguard-project.txt
It seems that there are sub-projects. If you want to update them
please use the --subprojects parameter.