I configured my android project to use ant. When building using the keyword release it fails with this message:
java.lang.NullPointerException
at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:239)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
It fails on build.xml line 249 which is included here:
<macrodef name="package-helper">
<attribute name="sign.package" />
<element name="extra-jars" optional="yes" />
<sequential>
<apkbuilder
outfolder="${out.absolute.dir}"
basename="${ant.project.name}"
signed="@{sign.package}"
debug="${manifest.debuggable}"
verbose="${verbose}"> **LINE 249 IS HERE**
<file path="${intermediate.dex.file}" />
<sourcefolder path="${source.absolute.dir}" />
<sourcefolder refid="android.libraries.src" />
<jarfolder path="${external.libs.absolute.dir}" />
<jarfolder refid="android.libraries.libs" />
<nativefolder path="${native.libs.absolute.dir}" />
<nativefolder refid="android.libraries.libs" />
<extra-jars/>
</apkbuilder>
</sequential>
</macrodef>
That is called from line 401 which contains these lines:
<target name="-package-release" depends="-dex, -package-resources">
<package-helper sign.package="false" />
</target>
It looks like there is some problem with ApkBuilderTask.java but I don’t know how/where to get the source of ApkBuilderTask.java. Has anyone run into this problem and found a solution? I’m using android SDK tools revision 7 if that helps.
Note: Running “ant debug” or “ant release” all comes out to the same result.
This is a change introduced in the r7 tools. You need to update the
<apkbuilder>task in yourbuild.xml, in the ways that saturnine points out above.Given that this error only happens when you customize your build.xml, I think you need to go back and redo the customizations. If you look for
$ANDROID_SDK/tools/ant/ant_rules_r3.xmland paste them into yourbuild.xml(replacing the definitions that you pasted in last time), it should fix your problems.You may be able to get away without customizations, as the new version of the rules are far more customizable, and include
-pre-compileand-post-compilehooks.