当我尝试编译build.xml文件时,出现以下错误:
建立失败
C:\Users\workspace\testrepo\src\build.xml:36: Compile failed; see the compiler error output for details.
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1150)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:912)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
有人可以帮助我吗?
答案 0 :(得分:5)
在构建期间早先发生了编译错误。在同一输出日志文件中查找该错误并尝试修复它。
答案 1 :(得分:2)
以下解决方案对我有用:
1)定义以下类:
package somepackage;
import org.apache.tools.ant.taskdefs.Javac;
import org.apache.tools.ant.types.Commandline;
import org.eclipse.jdt.core.JDTCompilerAdapter;
public class JDTCompiler15 extends JDTCompilerAdapter {
@Override
public void setJavac(Javac attributes) {
if (attributes.getTarget() == null) {
attributes.setTarget("1.6");
}
if (attributes.getSource() == null) {
attributes.setSource("1.6");
}
super.setJavac(attributes);
}
// THIS METHOD IS RESPONSIBLE FOR PRINGTING THE ERRORS/WARNING.
@Override
protected void logAndAddFilesToCompile(Commandline cmd) {
super.logAndAddFilesToCompile(cmd);
System.err.println(cmd.toString());
}
}
2)添加以下VM参数:-Dbuild.compiler = somepackage.JDTCompiler15
答案 2 :(得分:2)
要查看给定命令下的日志使用中的编译错误:
LayoutInflater mInflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View textview= (View) mInflater.inflate(R.layout.item, null);
TextView myTextView = (TextView) textview.findViewById(R.id.helloText);
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/custom_font.ttf");
myTextView.setTypeface(tf);
它将在您的结帐目录中创建一个完整的日志。所以现在你可以检查那里的实际错误。
答案 3 :(得分:0)
如果您使用Weblogic生成客户端,则必须将“weblogic.jar”从安装目录添加到Additional Classpath中,以便Ant知道Ant.tools ....的存在位置。
我遇到了同样的问题,我试图解决这个问题而不是将其添加为额外的类路径,因为我将所有的jar复制到我的项目中,但仍然出现此错误。
答案 4 :(得分:0)
在我的情况下,一个类中有一个未使用的import语句,其包在其他地方找不到,但由于我从另一个项目复制了该类而被复制了。即使错误日志本身不是明确的,它还是在错误日志中被列为“未找到软件包”。我必须仔细搜索本例生成的所有警告。