让Android项目的build.xml在不同机器上自动更新的方法

以前做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。按照需要设定就行了。


转载于:https://my.oschina.net/BigSea123/blog/356401

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值