I think this is a bug and Android should fix it.
I encountered the same problem and wasted a lot of time to come up with a
really lousy hack for it.
Please take a look at these lines in android-sdk/tools/ant/build.xml, which
Android uses to instruct ant to build the project properly. These lines are
specifically used for generating jars for library projects.
<jar destfile="${out.library.jar.file}">
<fileset dir="${out.classes.absolute.dir}"
includes="**/*.class"
excludes="${project.app.package.path}/R.class
${project.app.package.path}/R$*.class
${project.app.package.path}/Manifest.class/${project.app.package.path}/Manifest$*.class
${project.app.package.path}/BuildConfig.class"/>
<fileset dir="${source.absolute.dir}"
excludes="**/*.java ${android.package.excludes}" />
</jar>
This invocation of jar somehow cannot interpret the parameter <fileset
dir="${source.absolute.dir}"> correctly, where we intended to pass in
multiple directories. For example, in your case, the whole string
"/Users/grantland/development/kiip/android-sdk/kiip/src;libs/apache/src/java;libs/signpost/signpost-core/src/main/java;libs/signpost/signpost-commonshttp4/src/main/java;libs/gchttprequest/src"
is passed in as a source directory. What we really want is to pass multiple
source directories.
So here is what I did to fix it
<jar destfile="${out.library.jar.file}">
<fileset dir="${out.classes.absolute.dir}"
includes="**/*.class"
excludes="${project.app.package.path}/R.class
${project.app.package.path}/R$*.class
${project.app.package.path}/Manifest.class/${project.app.package.path}/Manifest$*.class
${project.app.package.path}/BuildConfig.class"/>
<fileset dir="${jarsource1.absolute.dir}"
excludes="**/*.java ${android.package.excludes}" />
<fileset dir="${jarsource2.absolute.dir}"
excludes="**/*.java ${android.package.excludes}" />
<fileset dir="${jarsource3.absolute.dir}"
excludes="**/*.java ${android.package.excludes}" />
... ...
</jar>
and I need to specify in my "build.properties"
jarsource1.absolute.dir=/Users/grantland/development/kiip/android-sdk/kiip/src
jarsource2.absolute.dir=libs/apache/src/java
... ...
Please let me know if there are better fixes.
Thank you,
Yue
On Thursday, October 27, 2011 8:53:27 PM UTC-4, Grantland wrote:
>
> I don't know if this is a bug or if i'm doing something wrong, but I
> am unable to build my Android library with multiple source directories
> using ant with ADK r14.
>
> My ant.properties:
> source.dir=src;libs/apache/src/java;libs/signpost/signpost-core/src/
> main/java;libs/signpost/signpost-commonshttp4/src/main/java;libs/
> gchttprequest/src
>
> My build.xml is clean and created by android update project -p .
>
>
> I run:
> $ ant clean release
>
>
> Crashlog:
> ...
>
> -compile:
> [javac] /Developer/android-sdk/tools/ant/build.xml:600: warning:
> 'includeantruntime' was not set, defaulting to
> build.sysclasspath=last; set to false for repeatable builds
> [javac] Compiling 68 source files to /Users/grantland/development/
> kiip/android-sdk/kiip/bin/classes
> [javac] Note: /Users/grantland/development/kiip/android-sdk/kiip/
> libs/signpost/signpost-core/src/main/java/oauth/signpost/
> AbstractOAuthProvider.java uses or overrides a deprecated API.
> [javac] Note: Recompile with -Xlint:deprecation for details.
> [echo] Creating library output jar file...
>
> BUILD FAILED
> /Developer/android-sdk/tools/ant/build.xml:580: The following error
> occurred while executing this line:
> /Developer/android-sdk/tools/ant/build.xml:620: /Users/grantland/
> development/kiip/android-sdk/kiip/src;libs/apache/src/java;libs/
> signpost/signpost-core/src/main/java;libs/signpost/signpost-
> commonshttp4/src/main/java;libs/gchttprequest/src does not exist.
>
>
> I've checked and all my source directories exist and the lines in the
> main build.xml it crashes in is:
> 620: <jar destfile="${out.library.jar.file}">
> 621: <fileset dir="${out.classes.absolute.dir}"
> excludes="**/R.class **/R$*.class"/>
> 622: <fileset dir="${source.absolute.dir}"
> excludes="**/*.java ${android.package.excludes}" />
> 623: </jar>
>
>
> I'm pretty sure line 623 causes the crash since fileset is unable to
> accept multiple directories. I can get around this by copying the
> entire -compile target and commenting out line 622 and it works.
>
> Am I doing something wrong, or is this a bug?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en