今天用ant打包时,出现如下错误
错误信息:
D:\android-sdk\android-sdk\tools\ant\build.xml:649: The following error occurred
while executing this line:
D:\android-sdk\android-sdk\tools\ant\build.xml:694: Execute failed: java.io.IOEx
ception: Cannot run program "D:\workspace\Test\${aapt}": CreateProcess error=2,
?????????
...
Caused by: java.io.IOException: CreateProcess error=2, ?????????
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:189)
at java.lang.ProcessImpl.start(ProcessImpl.java:133)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
... 46 more
解决方案:
在build.xml文件中添加,如下配置:
<!-- tools location -->
<property name="android.tools.dir" location="${sdk.dir}/tools" />
<property name="android.platform.tools.dir" location="${sdk.dir}/platform-tools" />
<property name="android.buildtools.dir" location="${sdk.dir}/build-tools/<span style="color:#cc0000;"><strong><u>21.1.2</u></strong></span>" />
<condition property="exe" value=".exe" else=""><os family="windows" /></condition>
<condition property="bat" value=".bat" else=""><os family="windows" /></condition>
<property name="adb" location="${android.platform.tools.dir}/adb${exe}" />
<property name="lint" location="${android.tools.dir}/lint${bat}" />
<property name="zipalign" location="${android.buildtools.dir}/zipalign${exe}" />
<property name="aidl" location="${android.platform.tools.dir}/aidl${exe}" />
<property name="aapt" location="${android.buildtools.dir}/aapt${exe}" />
<property name="dx" location="${android.buildtools.dir}/dx${bat}" />
<property name="renderscript" location="${android.buildtools.dir}/llvm-rs-cc${exe}"/>
<property name="lint" location="${android.tools.dir}/lint${bat}" />
错误原因:../ant/build.xml没有关于tools的配置,我这里用的build-tools是21.1.2