我试图使用测试apk文件在第三方apk文件上运行espresso黑盒测试。我已经在build.gradle中设置了testApplicationId,在AndroidManifest.xml中设置了targetPackage。
这是我运行的命令:
adb install app-debug.apk
Success
adb install app-debug-androidTest.apk
Success
adb shell am instrument -w com.example.android.testing.espresso.WikipediaTester/android.support.test.runner.AndroidJUnitRunner
INSTRUMENTATION_RESULT: shortMsg=Process crashed.
INSTRUMENTATION_CODE: 0
这是tomcat日志:
09-11 22:22:17.065 8576 8576 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<<
09-11 22:22:17.098 8576 8576 W app_process: Unexpected CPU variant for X86 using defaults: x86
09-11 22:22:17.116 8576 8576 D AndroidRuntime: Calling main entry com.android.commands.am.Am
09-11 22:22:17.118 1510 2317 I ActivityManager: Force stopping org.wikipedia.alpha appid=10102 user=0: start instr
09-11 22:22:17.123 8586 8586 I zygote : Not late-enabling -Xcheck:jni (already on)
09-11 22:22:17.130 1510 2317 I ActivityManager: Start proc 8586:org.wikipedia.alpha/u0a102 for added application org.wikipedia.alpha
09-11 22:22:17.131 8586 8586 W zygote : Unexpected CPU variant for X86 using defaults: x86
09-11 22:22:17.149 8586 8586 W zygote : Found duplicate classes, falling back to extracting from APK : /data/app/org.wikipedia.alpha-X9wevNAQOGt3rTh-c4Ydpg==/base.apk
09-11 22:22:17.149 8586 8586 W zygote : NOTE: This wastes RAM and hurts startup performance.
09-11 22:22:17.149 8586 8586 W zygote : Found duplicated class when checking oat files: 'Landroid/support/annotation/AnimRes;' in /data/app/org.wikipedia.alpha-X9wevNAQOGt3rTh-c4Ydpg==/base.apk and /data/app/com.example.android.testing.espresso.WikipediaTester-iiYiial_oKwqZvmMrjx_Zw==/base.apk
09-11 22:22:17.149 8586 8586 W zygote :
09-11 22:22:17.279 8586 8586 W System : ClassLoader referenced unknown path:
09-11 22:22:17.281 8586 8586 D AndroidRuntime: Shutting down VM
09-11 22:22:17.282 8586 8586 E AndroidRuntime: FATAL EXCEPTION: main
09-11 22:22:17.282 8586 8586 E AndroidRuntime: Process: org.wikipedia.alpha, PID: 8586
09-11 22:22:17.282 8586 8586 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{com.example.android.testing.espresso.WikipediaTester/android.support.test.runner.AndroidJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "android.support.test.runner.AndroidJUnitRunner" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /system/vendor/lib]]
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5730)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at android.app.ActivityThread.-wrap1(Unknown Source:0)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:105)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6541)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.test.runner.AndroidJUnitRunner" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /system/vendor/lib]]
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5728)
09-11 22:22:17.282 8586 8586 E AndroidRuntime: ... 8 more
09-11 22:22:17.284 8586 8586 I Process : Sending signal. PID: 8586 SIG: 9
09-11 22:22:17.328 1510 1522 I ActivityManager: Process org.wikipedia.alpha (pid 8586) has died: fore FGS
09-11 22:22:17.329 1510 1522 W ActivityManager: Crash of app org.wikipedia.alpha running instrumentation ComponentInfo{com.example.android.testing.espresso.WikipediaTester/android.support.test.runner.AndroidJUnitRunner}
09-11 22:22:17.329 1510 1522 I ActivityManager: Force stopping org.wikipedia.alpha appid=10102 user=0: finished inst
09-11 22:22:17.330 1510 8604 W Binder : Outgoing transactions from this process must be FLAG_ONEWAY
09-11 22:22:17.330 1510 8604 W Binder : java.lang.Throwable
09-11 22:22:17.330 1510 8604 W Binder : at android.os.BinderProxy.transact(Binder.java:736)
09-11 22:22:17.330 1510 8604 W Binder : at android.app.IInstrumentationWatcher$Stub$Proxy.instrumentationFinished(IInstrumentationWatcher.java:160)
09-11 22:22:17.330 1510 8604 W Binder : at com.android.server.am.InstrumentationReporter$MyThread.run(InstrumentationReporter.java:86)
09-11 22:22:17.331 8576 8576 D AndroidRuntime: Shutting down VM
答案 0 :(得分:0)
想出来,从androidTest转移到主