Android ant脚本中未设置"includeAntRuntime"?

11

我在 Android Ant 脚本中没有将 "includeAntRuntime" 设置为 false,这使得每次构建应用程序时都会出现令人烦恼的警告。

[javac] /Users/dwang/Library/android/android-sdk-mac_x86/tools/ant/main_rules.xml:361: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

请查看文件 android-sdk-*/tools/ant/main_rules.xml 的第354行。

            <javac encoding="${java.encoding}"
                    source="${java.source}" target="${java.target}"
                    debug="true" extdirs=""
                    destdir="${out.classes.absolute.dir}"
                    bootclasspathref="android.target.classpath"
                    verbose="${verbose}"
                    classpath="${extensible.classpath}"
                    classpathref="jar.libs.ref">
                <src path="${source.absolute.dir}" />
                <src path="${gen.absolute.dir}" />
                <src refid="project.libraries.src" />
                <classpath>
                    <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
                </classpath>
            </javac>

看起来我无法轻松地修复它,除非直接修改那个文件?Android团队,请修复一下吧?


这篇文章可能对使用ANT构建Android应用程序很有帮助:http://www.enterra-inc.com/techzone/using_ant_android_applications_building/ - user1146890
2个回答

14

对于Android SDK的解决方法是将build.sysclasspath属性设置为"last",这将消除虚假警告。

可以通过在项目的build.properties文件中分配属性值来实现此操作。

# You can use this to override default values such as
#  'source.dir' for the location of your java source folder and
#  'out.dir' for the location of your output folder.
out.dir=build
gen.dir=build/gen

# Suppress the javac task warnings about "includeAntRuntime"
build.sysclasspath=last

build.properties也被称为ant.properties吗? - Sam Wilson
我还没有找到build.properties文件,即使我创建了这个文件,仍然会打印出警告。但是将其添加到project.properties中将解决此问题。 我能否配置我的SDK,使得在创建Android项目时自动将此代码添加到project.properties中? - Frank Cheng

1

这是由Ant 1.8引入的一个错误特性导致的。只需在javac任务中添加一个该名称的属性,将其设置为false,然后忘记它曾经发生过。

即在您的javac Ant任务中设置includeAntRuntime属性。Ant用户手册提供了以下属性描述:“属性includeAntRuntime默认为yes,除非设置了build.sysclasspath。通常最好将其设置为false,以便脚本的行为不会受到其运行环境的影响。”


感谢您的评论。实际上,这是一个很容易解决的问题,但对于Android SDK来说并不是那么简单。目标在Android SDK脚本中定义。 - dongshengcn

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接