4

升级到 v20 SDK 工具后,我在尝试运行我的 Ant 构建时收到此错误。

sdk.dir 属性正确且经过验证(添加到 build.xml 中的输出)。解包 anttasks.jar 似乎最新工具中确实缺少 NewSetupTask。

META-INF/
META-INF/MANIFEST.MF
com/
com/android/
com/android/ant/
com/android/ant/RenderScriptTask.class
com/android/ant/SingleDependencyTask$1.class
com/android/ant/PropertyByReplaceTask.class
com/android/ant/BuildTypedTask.class
com/android/ant/AaptExecTask$1.class
com/android/ant/AaptExecTask$ResFolderInputPath.class
com/android/ant/AaptExecTask$NoCompress.class
com/android/ant/ApkBuilderTask.class
com/android/ant/GetLibraryPathTask.class
com/android/ant/InputPath.class
com/android/ant/RenderScriptTask$OptLevel.class
com/android/ant/TaskHelper.class
com/android/ant/XPathTask.class
com/android/ant/ManifestMergerTask.class
com/android/ant/DependencyHelper$LibraryProcessor.class
com/android/ant/CheckEnvTask.class
com/android/ant/RenderScriptTask$1.class
com/android/ant/ApkBuilderTask$SourceFolderInputPath.class
com/android/ant/DependencyHelper$JarProcessor$1.class
com/android/ant/ComputeDependencyTask.class
com/android/ant/SingleInputOutputTask.class
com/android/ant/GetLibraryPathTask$1.class
com/android/ant/RenderScriptTask$RenderScriptProcessor.class
com/android/ant/SignApkTask.class
com/android/ant/DependencyHelper$JarProcessor.class
com/android/ant/SignApkTask$NullZipFilter.class
com/android/ant/DependencyHelper$AdvancedLibraryProcessor.class
com/android/ant/DependencyGraph.class
com/android/ant/ComputeDependencyTask$1.class
com/android/ant/DexExecTask.class
com/android/ant/MultiFilesTask.class
com/android/ant/AidlExecTask$1.class
com/android/ant/DependencyHelper.class
com/android/ant/AidlExecTask.class
com/android/ant/BuildConfigTask.class
com/android/ant/ApkBuilderTask$1.class
com/android/ant/AaptExecTask.class
com/android/ant/SingleDependencyTask.class
com/android/ant/DependencyGraph$1.class
com/android/ant/ZipAlignTask.class
com/android/ant/GetTypeTask.class
com/android/ant/GetEmmaFilterTask.class
com/android/ant/IfElseTask.class
com/android/ant/DependencyGraph$DependencyStatus.class
com/android/ant/AidlExecTask$AidlProcessor.class
com/android/ant/ComputeProjectClasspathTask.class
com/android/ant/SingleDependencyTask$InputPathFactory.class
com/android/ant/GetTargetTask$1.class
com/android/ant/MultiFilesTask$DisplayType.class
com/android/ant/MultiFilesTask$SourceProcessor.class
com/android/ant/GetProjectPathsTask.class
com/android/ant/SignApkTask$1.class
com/android/ant/GetTargetTask.class
com/android/ant/ComputeDependencyTask$2.class
com/android/ant/GetLibraryPathTask$LeafProcessor.class
anttasks.properties

它去哪儿了?

4

3 回答 3

7

The problem stems from the fact that I am using a fully customized build.xml file. As such, it contains the following custom ant task definitions:

<taskdef name="setup"
    classname="com.android.ant.NewSetupTask"
    classpathref="android.antlibs" />

<taskdef name="aapt"
    classname="com.android.ant.AaptExecTask"
    classpathref="android.antlibs" />

<taskdef name="aidl"
    classname="com.android.ant.AidlExecTask"
    classpathref="android.antlibs" />

<taskdef name="renderscript"
    classname="com.android.ant.RenderScriptTask"
    classpathref="android.antlibs" />

<taskdef name="dex"
    classname="com.android.ant.DexExecTask"
    classpathref="android.antlibs" />

<taskdef name="apkbuilder"
    classname="com.android.ant.ApkBuilderTask"
    classpathref="android.antlibs" />

<taskdef name="zipalign"
    classname="com.android.ant.ZipAlignTask"
    classpathref="android.antlibs" />

<taskdef name="xpath"
    classname="com.android.ant.XPathTask"
    classpathref="android.antlibs" />

<taskdef name="if"
    classname="com.android.ant.IfElseTask"
    classpathref="android.antlibs" />

One or more of these are no longer provided by the anttasks.jar library. In comparing my build.xml file with the one located {sdk.dir}/tools/ant/build.xml I notice that these definitions have been replaced with the following:

<taskdef resource="anttasks.properties" classpathref="android.antlibs" />

Replacing the old task defs. in my build.xml file with this new task def statement removes the reference to missing tasks and fixes my problem.

于 2012-07-20T21:55:27.520 回答
2

检查您的 anttask.jar 下android-sdks\tools\lib

在你的build.xml 上,它可能是anttask.jar新的 sdk,它的名字是ant-task.jar. 因此,更改 xml 或文件系统上的名称。

于 2013-08-07T01:44:40.677 回答
0

使用 [ANDROID_HOME]\android-sdk\tools\ant 下更新的 build.xml,无需添加自定义 ant 任务定义

于 2012-07-30T06:48:05.803 回答