我正在使用Robotium来自动化我的应用测试。我的应用程序有1个活动(ActionBarActivity)和2个片段(使用support.v4.app.Fragment)。该应用程序工作正常,但当我尝试运行Robotium测试时,我在尝试创建一个新的Solo实例时收到错误。
solo = new Solo(getInstrumentation(), getActivity());
Logcat输出:
java.lang.NoSuchMethodError: No static method setOnApplyWindowInsetsListener(Landroid/view/View;Landroid/support/v4/view/OnApplyWindowInsetsListener;)V in class Landroid/support/v4/view/ViewCompat; or its super classes (declaration of 'android.support.v4.view.ViewCompat' appears in /data/app/com.mycompany.mytrip.test-1/base.apk)
E/AndroidRuntime( 5220): at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:304)
E/AndroidRuntime( 5220): at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:225)
E/AndroidRuntime( 5220): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
E/AndroidRuntime( 5220): at com.mycompany.mytrip.activities.MainActivity.onCreate(MainActivity.java:38)
E/AndroidRuntime( 5220): at android.app.Activity.performCreate(Activity.java:5933)
E/AndroidRuntime( 5220): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime( 5220): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
E/AndroidRuntime( 5220): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
E/AndroidRuntime( 5220): at android.app.ActivityThread.access$800(ActivityThread.java:144)
E/AndroidRuntime( 5220): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
E/AndroidRuntime( 5220): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 5220): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 5220): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime( 5220): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 5220): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 5220): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime( 5220): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
W/ActivityManager( 1229): Error in app com.mycompany.mytrip running instrumentation ComponentInfo{com.mycompany.mytrip.test/android.test.InstrumentationTestRunner}:
W/ActivityManager( 1229): java.lang.NoSuchMethodError
W/ActivityManager( 1229): java.lang.NoSuchMethodError: No static method setOnApplyWindowInsetsListener(Landroid/view/View;Landroid/support/v4/view/OnApplyWindowInsetsListener;)V in class Landroid/support/v4/view/ViewCompat; or its super classes (declaration of 'android.support.v4.view.ViewCompat' appears in /data/app/com.mycompany.mytrip.test-1/base.apk)
D/AndroidRuntime( 5209): Shutting down VM
任何建议都非常感谢!