5

this is an android project and my ant build script sometimes fails when it decides to treat warnings as errors when running the javac program. Seriously, it only does this sometimes, which is a different question I may ask.

It will print errors and abruptly cancel the build

[javac] 1 error

[javac] 9 warnings

as I did deeper I see the "error" is

error: warnings found and -Werror specified

which is not anything I explicitly set. Now this may be an argument buried deep in the build.xml file, or maybe in this particular sub library's build.xml file in one particular condition I don't currently know about

It is the android facebook sdk that causes this, sometimes. But there is no Werror argument within the ant build.xml files but I want to disable it or work around it

This is for a build server, where I have other conditions to stop a build. Inconsistent ant and javac issues don't really have a place.

but any insight about it is appreciated.

CQM
  • 42,592
  • 75
  • 224
  • 366
  • can you post the task that calls I'd expect to see something like but I trust you that's not the case... perhaps compilerarg is a property defined in a property file? are there any ant files included in the build.xml you're calling? – thekbb Sep 10 '13 at 22:19

1 Answers1

2

The file "tools/ant/build.xml" under my Android SDK directory contains the following:

<property name="java.compilerargs" value="" />

Perhaps the Android SDK used by the build that fails due to warnings being treated like errors includes "-Werror" in the compiler args? (If not, a recursive grep for "compilerargs" in the directory of the offending Android SDK instance could find the culprit.)

UPDATE:

On the other hand, that's in my Android SDK, the property is not in itself mandatory -- it just happens to be used here:

<!-- Compiles this project's .java files into .class files. -->
<target name="-compile" depends="-pre-build, -build-setup, -code-gen, -pre-compile">
    <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
        <!-- merge the project's own classpath and the tested project's classpath -->
        <path id="project.javac.classpath">
            <path refid="project.all.jars.path" />
            <path refid="tested.project.classpath" />
            <path path="${java.compiler.classpath}" />
        </path>
        <javac encoding="${java.encoding}"
                source="${java.source}" target="${java.target}"
                debug="true" extdirs="" includeantruntime="false"
                destdir="${out.classes.absolute.dir}"
                bootclasspathref="project.target.class.path"
                verbose="${verbose}"
                classpathref="project.javac.classpath"
                fork="${need.javac.fork}">
            <src path="${source.absolute.dir}" />
            <src path="${gen.absolute.dir}" />
            <compilerarg line="${java.compilerargs}" />
        </javac>

The element that has to be there is the "compilerarg" one on the next-to-last line, so a grep for "compilerarg" instead of "compilerargs" would be the better choice.

  • okay, I am using Android 4.2.2 as my target sdk. Can you look into this? but maybe one of my library projects was using a different Android SDK, hmmmm – CQM Sep 12 '13 at 05:03
  • If you build with more than one Android SDK (for example if you build on different machines or use more than one SDK version), then perhaps only one of these SDKs has the problem. If you can figure out which one based on which builds fail, you can grep that particular SDK for "compilerargs", otherwise you may need to grep through all SDKs on all machines that you use for building. I don't think you can find the source of the problem without (or at least easier than with) the file content search though. –  Sep 12 '13 at 05:15
  • I think it is android 4.2.2, which I believe I want to use – CQM Sep 12 '13 at 15:04
  • I ran this command from its folder `android-17 user$ grep -R -i -v compilerargs *` – CQM Sep 12 '13 at 15:10
  • I ran this command from its folder `android-17 user$ grep -rl 'compilerargs' .` and no luck, it isn't seen there – CQM Sep 12 '13 at 15:20
  • You're right, the property may not be defined in your Android SDK distribution, it is the 'compilerarg' (without 's') argument that would be needed to adjust the behavior of 'javac'. Would you mind grepping again without the 's' at the end? –  Sep 12 '13 at 16:02
  • what is the exact grep command you want me to run from my android-17 directory? – CQM Sep 12 '13 at 19:55
  • I would suggest that you run the same one you did, but for 'compilerarg' instead of 'compilerargs'. More exactly: `grep -rl compilerarg .` And if that fails, then I'd do a `grep -rl Werror .` because that -Werror has to come from somewhere. –  Sep 12 '13 at 22:07
  • unfortunately, I have not come to a resolution with this, in the android-17 folder both of these search strings returned nothing. I guess it was helpful to narrow down some possibilities, but I suspect the issue is something in the build.xml file – CQM Sep 16 '13 at 16:40
  • in the ant build.xml file, this is present `` and `` , similar lines are also in the uibuild.xml file, but they have no arguments – CQM Sep 16 '13 at 19:09