taskdef无法找到类com.android.ant.GetUiTargetTask所需的类:com / android / utils / ILogger

时间:2017-03-03 11:18:12

标签: android android-studio ant

将Android Studio更新到版本2.3后,当我创建项目时出现此错误

  

/Users/xxx/Work/yyy/build.xml:96:taskdef无法找到类com.android.ant.GetUiTargetTask所需的类:com / android / utils / ILogger           使用类加载器AntClassLoader [/Users/xxx/Library/Android/sdk/tools/lib/ant-tasks.jar:/Users/xxx/Library/Android/sdk/tools/lib/kxml2-2.3.0.jar:/用户/ XXX /库/安卓/ SDK / tools / lib目录/ GSON-2.2.4.jar:/Users/xxx/Library/Android/sdk/tools/lib/commons-compress-1.8.1.jar:/用户/ XXX /库/安卓/ SDK / tools / lib目录/ HttpClient的-4.1.1.jar:/Users/xxx/Library/Android/sdk/tools/lib/httpmime-4.1.jar:/用户/ XXX /库/安卓/ SDK /工具/ lib中/的HttpCore-4.1.jar:/Users/xxx/Library/Android/sdk/tools/lib/commons-logging-1.1.1.jar:/用户/ XXX /库/安卓/ SDK /工具/ LIB /公地编解码器-1.4.jar]       在org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:612)       在org.apache.tools.ant.taskdefs.Definer.loadProperties(Definer.java:408)       在org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:264)       在org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)       at java.lang.reflect.Method.invoke(Method.java:498)       在org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)       at org.apache.tools.ant.Task.perform(Task.java:348)       在org.apache.tools.ant.Target.execute(Target.java:435)       在org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:180)       在org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)       在org.apache.tools.ant.Main.runBuild(Main.java:832)       在org.apache.tools.ant.Main.startAnt(Main.java:236)       在org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)       在org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)           引起:java.lang.NoClassDefFoundError:com / android / utils / ILogger       at java.lang.Class.forName0(Native Method)       在java.lang.Class.forName(Class.java:348)       在org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:579)       ......还有16个           引起:java.lang.ClassNotFoundException:com.android.utils.ILogger       在org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1384)       在org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1333)       在org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1088)       at java.lang.ClassLoader.loadClass(ClassLoader.java:357)       ......还有19个

这是build.xml中提到的代码行

<taskdef resource="anttasks.properties" classpathref="android.antlibs" />
<property name="exe" value="" />
<property name="bat" value="" />

在更新之前,我从未看到此错误。我如何解决这个错误。

2 个答案:

答案 0 :(得分:4)

您需要从仍然拥有它们的工具中复制上述文件,例如Windows版本:

ant/*
lib/ant-tasks.jar
lib/common.jar
lib/sdklib.jar
lib/guava-17.0.jar
lib/manifest-merger.jar

答案 1 :(得分:0)

我已经下载并安装了仍然有tools来解决此问题的25.2.3ant