【发布时间】:2010-10-13 11:07:53
【问题描述】:
我需要使用 Ant 脚本生成一个 apk 文件,但是我遇到了编译目标的问题。为了自动生成 Ant 脚本,我使用了带有命令 android update project 的 Android 工具。问题是这个项目依赖于另一个项目,所以我需要使用自定义编译任务。
出于这个原因,我已经覆盖了那个目标:我已经从 ant_rules_r3.xml 复制了已编译的任务,并且我已经像这样更改了 javac 任务(请参阅 cmets 了解我所做的更改):
<!--I've changed the target 1.5 to target 1.6 -->
<javac encoding="UTF8" target="1.6" debug="true" extdirs=""
destdir="${out.classes.absolute.dir}"
bootclasspathref="android.target.classpath"
verbose="${verbose}"
classpath="${extensible.classpath}"
classpathref="android.libraries.jars">
<src path="${source.absolute.dir}" />
<!--My project has two src directories -->
<src path="${source2.absolute.dir}" />
<src path="${gen.absolute.dir}" />
<src refid="android.libraries.src" />
<!--I've added here the src dir of the other project -->
<src path="${dep1.source.absolute.dir}"/>
<classpath>
<!--I've added here the lib dir of the other project -->
<fileset dir="${dep1.external.libs.absolute.dir}" includes="*.jar" />
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
<fileset dir="${extensible.libs.classpath}" includes="*.jar" />
</classpath>
</javac>
问题是当我使用ant compile 编译时,我得到以下错误:
[javac].... cannot find symbol
[javac] symbol : constructor IOException(java.lang.String,java.security.NoSuchAlgorithmException)
[javac] location: class java.io.IOException
[javac] throw new IOException("Algorithm not found", e);
似乎它是用 JDK 1.5 而不是 1.6 编译的,即使我已将目标属性设置为 1.6。我的电脑使用的是 Java 版本 1.6.0_20。
我尝试过使用javac compiler="javac1.6",但我得到了同样的错误。
我也设置了build.properties:
ant.build.javac.target=1.6
ant.build.javac.source=1.6
但它也不能解决问题。将其设置为 1.3 而不是 1.6 会导致更多错误,因此似乎使用的是我在此处设置的 JDK。
我怎样才能让它正确编译?
【问题讨论】:
标签: java android ant build-automation compilation