做Android项目做到好几年的程序,发现技术进步很慢,逐渐往管理发展。。于是, 要看开源项目,学习别人的成功经验,来解决项目中遇到的棘手问题。
于是看到了别人推荐的android的开源源码,找了一个与我现在做的项目差不多的。。FourSquare。。
下载。。。
打开官网,http://code.google.com/p/foursquared/source/checkout
发现下载链接变成了 hg clone https://code.google.com/p/foursquared/ (这个要用linux下载。。我是win7 64位)
于是发现 github 已经被google抛弃的悲催命运,以及tortoiseHg的新人上位, 于是找来篇如何在 win7 64位下 用tortoiseHg 下载 这个hg 的路径。。
文章路径: http://hi.baidu.com/niceyou/item/9f22b73f1ece7dc1382ffa5c
tortoiseHg的安装路径 http://tortoisehg.bitbucket.org/
然后, 把系统环境变量 path 多设置 这个tortoiseHg 的 路径,就可以下载。。
然后下载下来的目录结构里, 看了里面的文件, 里面根目录有个NOTES 文件,
打开发现里面要求你配置很多文件。。 这些在examples\里面,你要移到下面路径:
Templates are available in examples/
+ Create: main/res/values/credentials.xml
+ Create: tests/src/com/joelapenna/foursquared/test/TestConstants.java
+ Create: main/src/com/joelapenna/foursquard/FoursquaredSettings.java
Optional if using ant to build instead of Eclipse:
+ Create: main/local.properties
还有配置eclipse的, 在examples\eclipse 下面
Java > Code Style > Cleanup - Import examples/eclipse/cleanup.xml
Java > Code Style > Formatter - Import examples/eclipse/formatting.xml
Java > Code Style > Organize Imports - Import examples/eclipse/importorder
然后,就导入项目,
File > Import > Existing project - Browse to $foursquared/main
File > Import > Existing project - Browse to $foursquared/tests
结果发现strings.xml编译报错,
1,non-positional format; did you mean to add the formatted="false" attribute?
[出现条件] android string中出现类似于
Added Tip #%s %s
参照android官方文档
http://developer.android.com/guide/topics/resources/string-resource.html
上面这条语句改成:
Added Tip #%1$s %2$s
结果, 所有%s %d 都要改。。。
2,FoursquaredSettings 增加一个字段
public static final long CATEGORY_ICON_EXPIRATION = 60L * 60L * 24L * 7L * 1000L * 2L; // two weeks.
3,credentials.xml 文件 改为如下:
<string name="google_maps_api_key">0RKYBEQTAi6OUzkmXi1eyjKUPDGF1TgCf-uEtKA</string>
<string name="google_maps_api_key_release">0RKYBEQTAi6OUzkmXi1eyjKUPDGF1TgCf-uEtKA</string>
<string name="google_maps_api_key_debug">0RKYBEQTAi6NEKnd4A_jdnRIYgbcQJTV_3gnBOQ</string>
<string name="oauth_consumer_key">36eb0502d17f9bdd141b058ddf5656ba04a6d6cbb</string>
<string name="oauth_consumer_secret">0a7aec09f3b610caa036f0730bc50ec8</string>
<string name="dumpcatcher_url">https://dumpcatcher.appspot.com/add</string>
<string name="dumpcatcher_product_key">agtkdW1wY2F0Y2hlcnIPCxIHUHJvZHVjdBjd9zYM</string>
<string name="dumpcatcher_secret">dc9f845825194a668a716964f42eaf82</string>
<string name="test_dumpcatcher_url">http://10.0.2.2:8080/add</string>
<string name="test_dumpcatcher_product_key">agtkdW1wY2F0Y2hlcnINCxIHUHJvZHVjdBgCDA</string>
<string name="test_dumpcatcher_secret">4ceafc4082e345ec98972c00f035609b</string>
<string name="facebook_api_key">0cba5db5a00299787b6b8b4c6b6d13d6</string>
终于, 全部编译成功, 结果 一跑应用,我的手机不能装。。 用模拟器,结果发现输入用户名和密码后,报 Http 1.1 Bad Request .. 还是不能跑。。
只能改代码,让系统进入首页了。。还好有源码。。