正确的方法:
File->New->the->Android->Android Sample Project->Target Name(勾选) 具体例子
前提是事先安装了给版本API的Sample Sdk。
不正确的方法是:
File->New->the->Android->Android projects from existing code-->对应的SDK例程。
Eclipse Android Junit Test 测试实例 http://blog.csdn.net/songweb/article/details/7264521
第1步,新建一个Android项目,选择“create project from existing source”,并把路径指向samples/android-15/ApiDemos
第2步,再新建一个Android项目,依然通过“create project from existing source”的方式,这次把路径指向samples/android-15/ApiDemos/tests
这时候ADT会报错,因为它无法找到APIDemo项目。右键,选择Properties,在Java Build Path –> Projects中添加APIDemo项目即可。
第3步,以“Android Application”方式运行第一个项目(注意正确设置AVD),APIDemo将被安装到模拟器。
第4步,以“Android Application”方式运行第二个项目(注意正确设置AVD),APIDemo Test将被安装到模拟器。
第5步, 在eclipse中选中test项目,直接Run As “Android JUnit Test”既可以,测试结果会以图形化的方式返回。
那么,我们如何创建自己的test项目呢?
大致的步骤如下:
1、新建一个普通的Android项目,比如项目名为song,Package为com.song.web
2、新建一个Test项目,注意把Package填成com.song.web.tests,项目名任意,比如songtest,Application name任意
3、在songtest项目的Build Path中添加song项目
4、参照APIDemo Test项目的manifext.xml来修改songtest项目的manifest.xml
5、编写TestCase
Field requires API level 5 (current min is 1) 问题的解决 http://blog.sina.com.cn/s/blog_6714fba701018nup.html
android程序出现了奇怪的错误
解决办法:
Right click on the project folder > Android tools > Clear Link Markers
英文网站找的,细节就看不懂了。参见
http://stackoverflow.com/questions/10322482/android-lint-erroneously-thinks-min-sdk-version-is-1