1

当我ant使用使用 的项目进行构建时libgdx,出现一个奇怪的错误。它说com.google.gwt.dom.client.ImageElement没有找到一个类,但在代码中根本没有使用它。我怎样才能找到这门课的必要性?即使搜索整个项目也不会给出任何结果。它说错误在PixmapTextureAtlas.java:16类源),但没有使用ImageElement该类的代码。当然,添加包含com.google.gwt.dom.client.ImageElement类的库会有所帮助,但我想弄清楚为什么需要这个类。

这是 ant 日志中显示实际错误的位置:

Compiling 3 source files to /home/suseika/Projects/tendiwa/client/bin
/home/suseika/Projects/tendiwa/client/src/org/tendiwa/client/PixmapTextureAtlas.java:16: error: cannot access ImageElement
class file for com.google.gwt.dom.client.ImageElement not found

这是整个蚂蚁日志:

 /usr/lib/jvm/java-7-oracle/bin/java -Xmx128m -Xss2m -Dant.home=/opt/intellijidea/lib/ant -Dant.library.dir=/opt/intellijidea/lib/ant/lib -Dfile.encoding=UTF-8 -classpath /opt/intellijidea/lib/ant/lib/ant-apache-regexp.jar:/opt/intellijidea/lib/ant/lib/ant-swing.jar:/opt/intellijidea/lib/ant/lib/ant-apache-xalan2.jar:/opt/intellijidea/lib/ant/lib/ant-jdepend.jar:/opt/intellijidea/lib/ant/lib/ant-apache-resolver.jar:/opt/intellijidea/lib/ant/lib/ant-jsch.jar:/opt/intellijidea/lib/ant/lib/ant.jar:/opt/intellijidea/lib/ant/lib/ant-testutil.jar:/opt/intellijidea/lib/ant/lib/ant-launcher.jar:/opt/intellijidea/lib/ant/lib/ant-apache-bsf.jar:/opt/intellijidea/lib/ant/lib/ant-commons-logging.jar:/opt/intellijidea/lib/ant/lib/ant-netrexx.jar:/opt/intellijidea/lib/ant/lib/ant-junit.jar:/opt/intellijidea/lib/ant/lib/ant-commons-net.jar:/opt/intellijidea/lib/ant/lib/ant-apache-bcel.jar:/opt/intellijidea/lib/ant/lib/ant-antlr.jar:/opt/intellijidea/lib/ant/lib/ant-apache-log4j.jar:/opt/intellijidea/lib/ant/lib/ant-jai.jar:/opt/intellijidea/lib/ant/lib/ant-apache-oro.jar:/opt/intellijidea/lib/ant/lib/ant-jmf.jar:/opt/intellijidea/lib/ant/lib/ant-javamail.jar:/usr/lib/jvm/java-7-oracle/lib/tools.jar:/opt/intellijidea/lib/idea_rt.jar com.intellij.rt.ant.execution.AntMain2 -logger com.intellij.rt.ant.execution.IdeaAntLogger2 -inputhandler com.intellij.rt.ant.execution.IdeaInputHandler -buildfile /home/suseika/Projects/tendiwa/client/build.xml jar
build.xml
property
path
description
compile
ant
property
property
property
description
compile
mkdir
javac
jar
ant
property
description
_core_src_available
available
ontology
antcall
property
description
_core_src_available
available
_build_core
ant
property
property
compile
echo
/home/suseika/Projects/tendiwa/client
mkdir
javac
jar
jar
Building jar: /home/suseika/Projects/tendiwa/MainModule.jar
description
tempfile
mkdir
Created dir: /tmp/tendiwa373148820
unjar
Expanding: /home/suseika/Projects/tendiwa/MainModule.jar into /tmp/tendiwa373148820
Expanding: /home/suseika/Projects/tendiwa/tendiwa-backend.jar into /tmp/tendiwa373148820
Expanding: /home/suseika/Projects/tendiwa/tendiwa-ontology.jar into /tmp/tendiwa373148820
copy
Copying 1 file to /tmp/tendiwa373148820
java
Created item short_sword
Created item short_bow
Created item bucket
Created item boot
Created item steel_morningstar
Created item rifle_ammo
Created item handAxe
Created item iron_armor
Created item steel_mace
Created item jacket
Created item fedora
Created item wooden_arrow
Saving sources to /tmp/tendiwa373148820/ontology/src
tendiwa/resources/SoundTypes.java
tendiwa/resources/CharacterTypes.java
tendiwa/resources/ObjectTypes.java
tendiwa/resources/FloorTypes.java
tendiwa/resources/ItemTypes.java
tendiwa/resources/MaterialTypes.java
mkdir
mkdir
mkdir
Created dir: /tmp/tendiwa373148820/ontology/bin
javac
jar
Building jar: /home/suseika/Projects/tendiwa/tendiwa-ontology.jar
echo
Resources source code generated
ant
property
property
compile
echo
/home/suseika/Projects/tendiwa/client
mkdir
javac
jar
jar
jar
Building jar: /home/suseika/Projects/tendiwa/MainModule.jar
mkdir
javac
/home/suseika/Projects/tendiwa/client/build.xml:25: 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:606)
    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.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:809)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.Main.start(Main.java:180)
    at org.apache.tools.ant.Main.main(Main.java:268)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:30)
/home/suseika/Projects/tendiwa/client/build.xml (25:46)'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
Compiling 3 source files to /home/suseika/Projects/tendiwa/client/bin
/home/suseika/Projects/tendiwa/client/src/org/tendiwa/client/PixmapTextureAtlas.java:16: error: cannot access ImageElement
class file for com.google.gwt.dom.client.ImageElement not found
1 error
/home/suseika/Projects/tendiwa/client/build.xml:25: 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:606)
    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.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:809)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.Main.start(Main.java:180)
    at org.apache.tools.ant.Main.main(Main.java:268)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:30)
/home/suseika/Projects/tendiwa/client/build.xml:25: 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:606)
    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.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:809)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.Main.start(Main.java:180)
    at org.apache.tools.ant.Main.main(Main.java:268)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:30)

Ant build completed with 3 errors one warning in 4s at 10/30/13 3:09 AM

这是出现此错误的 ant 文件的一部分:

<path id="tendiwa.jars">
    <fileset dir="../libs">
        <include name="**/*.jar"/>
    </fileset>
    <pathelement path="../tendiwa-backend.jar"/>
    <pathelement path="../tendiwa-ontology.jar"/>
    <!--<fileset dir="/usr/share/java" includes="gwt*.jar"/>-->
</path>

<target name="compile">
    <ant dir="../MainModule" target="jar"/>
    <mkdir dir="bin"/>
    <javac destdir="bin" failonerror="true">
        <classpath>
            <path refid="tendiwa.jars"/>

            <!--temporary-->
            <pathelement path="../tendiwa-ontology.jar"/>
            <!--temporary-->
            <pathelement path="../MainModule.jar"/>
            <fileset dir="../libs" includes="**/*.jar"/>
        </classpath>
        <src>
            <pathelement path="Desktop/src"/>
            <pathelement path="src"/>
        </src>
    </javac>
</target>
4

2 回答 2

2

给定的库可能具有它不提供的依赖项,因此您的代码间接需要它。PixmapTextureAtlas.java:16确实引用了这个类,并且您使用PixmapTextureAtlas,因此您间接需要com.google.gwt.dom.client.ImageElement.

像 Maven 这样的工具可以添加依赖项/子依赖项并轻松管理它们。

于 2013-10-29T21:21:57.073 回答
1

我发现了为什么会这样。我不小心在类路径中添加了两个不同的 jar,它们是 class 的两个不同变体com.badlogic.gdx.graphics.Pixmap,一个依赖于 GWT,另一个是我需要的。问题是我不知道这种情况是可能的:)

于 2013-10-29T21:51:41.037 回答