还未发布过话题
  • 下面是我执行前的环境配置,给需要的同学个参考:
    1\使用 eclipse 导入工程:imports as android project;
    2\更改 project build target 为 7.1.1;
    3\更改 jdk complier compliance level 为 1.7(本地的 java -version 为 1.8);
    4\处理些报错提示,主要是添加 final;
    5\manifest 里面替换被测应用包名;
    6\Iteration.java 文件中,填写 LAUNCHER_ACTIVITY 和 homeActivity,登录相关的因为用不到用" "代替,其他用不到部分清空;
    7\因为项目没有登录页面,屏蔽 test_00_login 的代码;
    8\被测项目用的 v4 版本更新,更新 support-v4-23.3.0(删除自带的 support-v4 后通过 android tools 的 add support library 更新);
    9\安装后使用命令执行测试:adb shell am instrument -w -r -w -e debug false -e class application.iteration.Iteration#test_01_iteration 被测应用包名.test/com.heyniu.auto.InstrumentationTestRunner
    使用 eclipse 直接执行会报 Process crashed

  • 弄了好些时间还是跑不起来,测试启动后被测应用界面闪了下后报错:Test run failed: Instrumentation run failed due to 'java.lang.NullPointerException'
    logcat 的日志是:
    E/AndroidRuntime( 7643): java.lang.RuntimeException: Unable to start activity ComponentInfo{PACKAGENAME/PACKAGENAME.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.TaskStackBuilder android.support.v4.app.TaskStackBuilder.addParentStack(android.app.Activity)' on a null object reference
    E/AndroidRuntime( 7643): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
    E/AndroidRuntime( 7643): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
    E/AndroidRuntime( 7643): at android.app.ActivityThread.access$800(ActivityThread.java:144)
    E/AndroidRuntime( 7643): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
    E/AndroidRuntime( 7643): at android.os.Handler.dispatchMessage(Handler.java:102)
    E/AndroidRuntime( 7643): at android.os.Looper.loop(Looper.java:135)
    E/AndroidRuntime( 7643): at android.app.ActivityThread.main(ActivityThread.java:5221)
    E/AndroidRuntime( 7643): at java.lang.reflect.Method.invoke(Native Method)
    E/AndroidRuntime( 7643): at java.lang.reflect.Method.invoke(Method.java:372)
    E/AndroidRuntime( 7643): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    E/AndroidRuntime( 7643): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
    E/AndroidRuntime( 7643): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.TaskStackBuilder android.support.v4.app.TaskStackBuilder.addParentStack(android.app.Activity)' on a null object reference
    E/AndroidRuntime( 7643): at android.support.v7.app.AppCompatActivity.onCreateSupportNavigateUpTaskStack(AppCompatActivity.java:353)
    E/AndroidRuntime( 7643): at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:74)
    E/AndroidRuntime( 7643): at PACKAGENAME.MainActivity.onCreate(MainActivity.java:64)
    E/AndroidRuntime( 7643): at android.app.Activity.performCreate(Activity.java:5933)
    E/AndroidRuntime( 7643): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
    E/AndroidRuntime( 7643): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
    E/AndroidRuntime( 7643): ... 10 more
    W/ActivityManager( 562): Error in app PACKAGENAME running instrumentation ComponentInfo{PACKAGENAME.test/com.heyniu.auto.InstrumentationTestRunner}:
    W/ActivityManager( 562): java.lang.NullPointerException
    W/ActivityManager( 562): java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.TaskStackBuilder android.support.v4.app.TaskStackBuilder.addParentStack(android.app.Activity)' on a null object reference

    请问是哪里出问题了?对 robotium 不熟悉..