以前做android app,知道可以用ant来做打包签名的工作。但是在自己机器上能好好地build,去到别人的机器就总是出错。错误提示大多类似下面:
BUILD FAILED
/Applications/adt-bundle-mac-x86_64-20140702/sdk/extras/google/webdriver/SimpleApp/build.xml:83:
Cannot find /iApplications/adt-bundle-mac-x86_64-20140702/sdk/tools/ant/build.xml imported from
/Applications/adt-bundle-mac-x86_64-20140702/sdk/extras/google/webdriver/SimpleApp/build.xml
大致意思是找不到用来Import的build.xml文件。
上网查了一下,原因是build.xml使用了一个变量${sdk.dir}来存储不同机器上android sdk的位置。而${sdk.dir}是存储在local.properties里面的。local properties文件内容大致如下:
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked in Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/iApplications/adt-bundle-mac-x86_64-20140702/sdk
里面已经写到这个文件是用Android Tools自动生成的,因此不应该放到版本控制器(svn或者git)里面。那么,假如项目中别人已经commit了local.properties文件,我们需要怎么样重新自动生成它呢?答案很简单,一条命令:
android update project -p ./
这样它就会自动更新project中的相关设置,包括local.properties了。当然,前提是你已经把sdk加入到PATH中。
如果项目本身没有指定target,它会要求你设定target。按照需要设定就行了。