大佬教程收集整理的这篇文章主要介绍了android – 在启用multidexing的情况下,Instrumentation测试随机失败,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
默认gradle配置:
android { defaultConfig { applicationId "com.example.androidapp" minSdkVersion 16 targetSdkVersion 23 multiDexEnabled true testinstrumentationRunner "com.android.test.runner.MultiDexTestRunner" testProguardFile "proguard-test.txt" } }
还要为测试添加依赖项:
androidTESTCompile fileTree(dir: 'libs',include:'robotium-solo-5.3.0.jar') androidTESTCompile ('com.android.support:multidex-instrumentation:1.0.1') { exclude group: 'com.android.support',module: 'multidex' }
在AndroidManifest.xml中,我提到了应用程序标记:
<application android:name="StartupActivity" android:allowBACkup="true" android:icon="@mipmap/ic_launcher" android:label="@String/app_name" ...../>
我在StartupActivity中扩展了“android.support.multidex.MultiDexApplication”.仪器测试用例下降的时间我得到以下错误:
instrUMENTATION_RESULT: shortmsg=java.lang.IllegalAccessError instrUMENTATION_RESULT: longMsg=java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation instrUMENTATION_CODE: 0
logcat中的错误消息是:
W/dalvikvm﹕ Class resolved by unexpected DEX: Lcom/example/androidapp/StartupActivity;(0xa695df08):0x9910e000 ref [Landroid/support/multidex/MultiDexApplication;] Landroid/support/multidex/MultiDexApplication;(0xa695df08):0x99a2c000 W/dalvikvm﹕ (Lcom/example/androidapp/StartupActivity; had used a different Landroid/support/multidex/MultiDexApplication; during pre-verification) W/dalvikvm﹕ Unable to resolve superclass of Lcom/example/androidapp/StartupActivity; (540) W/dalvikvm﹕ Link of class 'Lcom/example/androidapp/StartupActivity;' @L_772_8@ D/AndroidRuntime﹕ ShutTing down VM W/dalvikvm﹕ threadid=1: thread exiTing with uncaught exception (group=0xa628c288)
测试类看起来有点像:
public class HelloActivityTest extends ActivityinstrumentationTESTCase2<HelloActivity> { private Solo solo; public HelloActivitytest() { super(HelloActivityTest.class); } @Override public void setUp() throws Exception { setActivityInitialTouchMode(false); solo = new Solo(getinstrumentation(),getActivity()); } public void test1() {} public void test2() {} }
我正在运行测试用例作为android测试.我无法理解哪个依赖项会弄乱代码.除此之外,代码的随机失败是持怀疑态度的.请帮忙.
以上是大佬教程为你收集整理的android – 在启用multidexing的情况下,Instrumentation测试随机失败全部内容,希望文章能够帮你解决android – 在启用multidexing的情况下,Instrumentation测试随机失败所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。