无法创建任务或键入checkenv原因名称未定义

时间:2013-06-12 20:02:33

标签: android ant jenkins cordova jenkins-plugins

我知道有一些与此相关的问题,但我想要做的是有点不同。

我在项目配置选项中指定的2个目标是

清洁 调试

默认情况下它们都可用,所以我不必为任何其他目标编写新代码。但我的构建仍然失败。

Started by user anonymous
[EnvInject] - Loading node environment variables.
Building in workspace /var/lib/jenkins/jenkins-data/jobs/anttest1/workspace
Checkout:workspace / /var/lib/jenkins/jenkins-data/jobs/anttest1/workspace - hudson.remoting.LocalChannel@4603278f
Using strategy: Default
Last Built Revision: Revision 17b9fd2ee52d01e7a425822f353222445e3a82c7 (EventMatrix_Cordova_App/HEAD, EventMatrix_Cordova_App/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from EventMatrix_Cordova_App
Seen branch in repository EventMatrix_Cordova_App/HEAD
Seen branch in repository EventMatrix_Cordova_App/master
Commencing build of Revision 17b9fd2ee52d01e7a425822f353222445e3a82c7 (EventMatrix_Cordova_App/HEAD, EventMatrix_Cordova_App/master)
Checking out Revision 17b9fd2ee52d01e7a425822f353222445e3a82c7 (EventMatrix_Cordova_App/HEAD, EventMatrix_Cordova_App/master)
Warning : There are multiple branch changesets here
[mysteryshopper_version2] $ ant -file build.xml -Dlabel=anttest1-42 clean
Buildfile: /var/lib/jenkins/jenkins-data/jobs/anttest1/workspace/mysteryshopper_version2/build.xml
  **[taskdef] Could not load definitions from resource anttasks.properties. It could not be found.
  [taskdef] Could not load definitions from resource emma_ant.properties. It could not be found.**

-**check-env**:

BUILD FAILED
/usr/local/lib/android-sdk-linux/tools/ant/build.xml:392: Problem: **failed to create task or type checkenv**
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.


Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE

有人可以帮我吗?

3 个答案:

答案 0 :(得分:7)

Android版本需要

<checkenv />,它位于Android SDK目录的库中。我遇到了同样的问题,发现原因是local.propertiesbuild.xml所需的buildAndroid.xml文件中的错误目录。以下是我的local.properties文件示例:

# 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=/Users/myusername/android-sdk-macosx

当我在Eclipse中时,这会自动生成,但是当Eclipse关闭并且我在命令行使用ant时,它没有更新,并且有一些其他用户的信息已经提交给SVN并且我检查了用svn更新。

我将其更新为指向我自己的Android SDK目录,一切都开始有效。

希望有所帮助!

答案 1 :(得分:2)

问题不在于anttasks.propertiesemma_ant.properties(至少对我而言)。我修改它的方式不同。我的目标build.xml有这些行

<property file="local.properties"/>
<property file="project.properties"/>
<property file="ant.properties"/>

奇怪的是,local.properties文件夹中缺少build.xml,而其他两个文件夹存在。幸运的是,由于我之前尝试使用Android Studio,即StudioProjects/<my project>/local.properties,我已经拥有它了。换句话说,它是由Android Studio自动创建的。如果你没有,那就是它的内容:

## This file is automatically generated by Android Studio.
# 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 Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri Apr 22 21:28:15 EEST 2016
ndk.dir=home/<user>/android-ndk-r11c
sdk.dir=home/<user>/Android/Sdk

因此,您基本上可以自己创建SDK,也可以指定NDK的路径。

我希望它有所帮助。

答案 2 :(得分:0)

我在更新构建工具时运行了antbuild导致文件访问冲突:) SDK Manager显示它已安装。删除并重新安装修复了问题。