robotium仅有APK

  1. APK包要签名,需要re-sign.jar(文件后面给下载)

    robotium仅有APK_第1张图片

  2. 如果是签名后的APK安装到手机或者SDK中

  3. 修改AndroidManifest.xml


    robotium仅有APK_第2张图片

    robotium仅有APK_第3张图片

  4. 编写用例

private static final String PACKAGE_NAME="com.lebo.mychebao.netauction";

private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.lebo.mychebao.netauction.ui.LauncherActivity";

//"com.lebo.mychebao.netauction.ui.LauncherActivity";

//"com.example.demo.MainActivity";

private Solo solo;

public demo() throws ClassNotFoundException {

//super(Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME));

super(PACKAGE_NAME, Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME));

}


protected void setUp() throws Exception {

super.setUp();

if (solo == null) {

solo = new Solo(getInstrumentation(), getActivity());

//solo = new Solo(getInstrumentation());

}

}


protected void tearDown() throws Exception {

super.tearDown();

}

public void test001() throws ClassNotFoundException{

//solo.waitForActivity(MainActivity.class, 5*1000);

solo.sleep(5*1000);

//assertTrue(solo.searchText("用户名:"));

solo.enterText(solo.getEditText(0), "123");

Button btn = solo.getButton("开始");

btn.clearFocus();

}

5.调试出错

at  setup的明细不表,如果是出现在solo = new Solo(getInstrumentation(), getActivity());

如此处理

a.删除Anroid dependency 的库

b.删除robotium的2个jar

c.重新导入robotium的jar

d.运行正常

robotium仅有APK_第4张图片

你可能感兴趣的:(robotium仅有APK)