views:

98

answers:

1

Hello,

I need to generate an apk file using an ant script but I'm having problems in the compile target. To generate automatically the ant script I've used the android tool with the command "android update project". The problem is that this project depends on another project so I need to do a custom compile task. For that reason I've overridden that target: I've copied the compiled task from ant_rules_r3.xml and I've changed the javac task like this (I include the comments of what I've changed):

<!--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>

The problem is that when I compile it (ant compile) I get the following error:

[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);

It seems as it's been compiled with JDK 1.5 instead of 1.6 though I have set the target property to 1.6. The java version of my computer is: java version "1.6.0_20". I've also tried to add to javac compiler="javac1.6", but I get the same error.

I've also set in myu build.properties:

ant.build.javac.target=1.6
ant.build.javac.source=1.6

but it doesn't solve the problem. If I set it to 1.3 instead of 1.6 it gets more errors so it seems it is using the JDK I'm setting here.

Any suggestion?

Thanks

+1  A: 

Because you've specified the bootclasspath to use the Android SDK classes, these will probably be the ones that contain the IOException class that does not implement the two-arg constructor with a Throwable second arg. That constructor was new in Java 6, but according to recent Android (2.2) docs, the Android version only has Java-1.5 style constructors, and doesn't implement the two newer constructors that take Throwable args.

You didn't mention whether you'd got this to build successfully before bringing in the second project - so I'd recommend checking your local Android boot classes to see what constructors IOException offers.

martin clayton