android - 构建 Android 时出现警告失败

标签 android ant

<分区>

Possible Duplicate:
Javac: Treat warnings as errors

我想更新我的 Android 项目的 ANT 脚本以在警告时失败,但似乎无法找到我该怎么做(我找不到要更新的 javac 元素)。我认为这是可能的?

明确一点,我不想在 Eclipse 中执行此操作,因为我希望我们的构建系统在有人引入新警告时失败。

最佳答案

要了解如何在 ant 中执行此操作,请参阅:Javac: Treat warnings as errors .从该链接:

<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath">
    <compilerarg value="-Werror"/>
</javac>

Android 向您隐藏了 javac 任务。如果您使用当前的 SDK 创建一个新的 android 项目,build.xml文件将描述如何编辑特定目标:

     The rules file is imported from
        <SDK>/tools/ant/
     Depending on the project type it can be either:
     - main_rules.xml
     - lib_rules.xml
     - test_rules.xml

     To customize existing targets, there are two options:
     - Customize only one target:
         - copy/paste the target into this file, *before* the
           <setup> task.
         - customize it to your needs.
     - Customize the whole script.
         - copy/paste the content of the rules files (minus the top node)
           into this file, *after* the <setup> task
         - disable the import of the rules by changing the setup task
           below to <setup import="false" />.
         - customize to your needs.

您需要打开 main_rules.xml 文件(如果您正在构建库,则打开 lib_rules),复制 <target name="compile">部分,并将其粘贴到构建脚本中的 <setup \> 之前标签。添加编译器 arg 以在出现上述错误时失败,您应该可以开始了。

关于android - 构建 Android 时出现警告失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7748222/

相关文章:

android - 我可以将我的 Android 应用程序构建为调试但使用发布 keystore 签名吗

使用 WebSphere MQ File Transfer Edition (MQ FTE) 传输多个文件的 Ant 脚本

maven-2 - 使用 Ant 模拟 Maven2 过滤机制

asp.net - 读取字符串中的分号时,nant 脚本中的 xmlpoke 出现问题

java - 在 Android 的 Canvas 上绘制一个又一个形状

java - Kotlin 中的错误但仅使用 Java - 类 kotlin.reflect.jvm.internal.FunctionCaller$FieldSetter

从另一个 Activity 导航回来时,Android Activity onCreate 被调用两次

android - 在android中的coverflow中的图像下方添加文本

android - 受信任应用程序的 Secure Rest API

ant - 如果在给定时间内未输入,如何使 Ant 提示使用默认值?