[英]When i run my android UIAutomator code, it shows error
When I run my android UIAutomator code, it shows following error. 当我运行我的Android UIAutomator代码时,它显示以下错误。
INSTRUMENTATION_RESULT: shortMsg=java.lang.RuntimeException
INSTRUMENTATION_RESULT:shortMsg = java.lang.RuntimeException
INSTRUMENTATION_RESULT: longMsg=com.android.ui.testingINSTRUMENTATION_RESULT:longMsg = com.android.ui.testing
INSTRUMENTATION_CODE: 0INSTRUMENTATION_CODE:0
I just ran the sample code given in developer.android.com 我刚刚运行了developer.android.com中给出的示例代码
How to solve this error? 如何解决这个错误?
Log attached below: 日志附在下面:
01-05 01:07:53.559: D/AndroidRuntime(5712): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
01-05 01:07:53.559: D/AndroidRuntime(5712): CheckJNI is ON
01-05 01:07:53.559: E/AndroidRuntime(5712): cannot open customer xml file
01-05 01:07:53.559: E/AndroidRuntime(5712): /system/csc/customer.xml can't open file
01-05 01:07:53.564: D/AndroidRuntime(5712): readGMSProperty: start
01-05 01:07:53.564: D/AndroidRuntime(5712): readGMSProperty: already setted!!
01-05 01:07:53.564: D/AndroidRuntime(5712): readGMSProperty: end
01-05 01:07:53.589: D/dalvikvm(5712): Trying to load lib libjavacore.so 0x0
01-05 01:07:53.599: D/dalvikvm(5712): Added shared lib libjavacore.so 0x0
01-05 01:07:53.609: D/dalvikvm(5712): Trying to load lib libnativehelper.so 0x0
01-05 01:07:53.609: D/dalvikvm(5712): Added shared lib libnativehelper.so 0x0
01-05 01:07:53.664: I/dalvikvm(5712): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
01-05 01:07:53.874: D/dalvikvm(5712): Note: class Landroid/app/ActivityManagerNative; has 152 unimplemented (abstract) methods
01-05 01:07:53.924: D/AndroidRuntime(5712): Calling main entry com.android.commands.uiautomator.Launcher
01-05 01:07:53.934: D/AndroidRuntime(5712): Shutting down VM
01-05 01:07:53.934: W/dalvikvm(5712): threadid=1: thread exiting with uncaught exception (group=0x40ffa2a0)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): uncaught exception
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): java.lang.RuntimeException: com.uia.example.my.LaunchSettings
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:95)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:82)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:76)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:237)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at dalvik.system.NativeStart.main(Native Method)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): Caused by: java.lang.ClassNotFoundException: com.uia.example.my.LaunchSettings
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at com.android.uiautomator.testrunner.TestCaseCollector.addTestClass(TestCaseCollector.java:83)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at com.android.uiautomator.testrunner.TestCaseCollector.addTestClass(TestCaseCollector.java:71)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at com.android.uiautomator.testrunner.TestCaseCollector.addTestClasses(TestCaseCollector.java:52)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:92)
01-05 01:07:53.939: E/UiAutomatorTestRunner(5712): ... 6 more
01-05 01:07:53.944: I/AndroidRuntime(5712): VM exiting with result code -1.
If you get a ClassNotFindException while running your uiautomator tests : 如果在运行uiautomator测试时遇到ClassNotFindException:
Some of us my get this error because their ROM puts the folder /data/dalvik-cache in read-only mode. 我们中的一些人得到此错误,因为他们的ROM将文件夹/ data / dalvik-cache置于只读模式。 That happened to me with Cyanogen for a S3.
我发现Cyanogen是一个S3。
In that case type, in bash : 在那种情况下,在bash中输入:
adb shell
su
chmod 777 /data/dalvik-cache
exit
rerun your tests and that should work. 重新运行你的测试,这应该工作。 As dalvik-cache is locked for apps, uiautomator can't ask dalvik to unzip the jar of your tests and dalvik won't find the its classes.
由于dalvik-cache被锁定为应用程序,uiautomator不能要求dalvik解压缩你的测试jar,而dalvik将找不到它的类。
See if removing the @UiThreadTest annotation or removing the runOnUiThread() call or re-factoring your tests work. 查看是否删除@UiThreadTest注释或删除runOnUiThread()调用或重新分解测试工作。 But without a logcat, difficult to understand where it's coming from.
但是没有logcat,很难理解它的来源。
Had the same problem. 有同样的问题。 Most demos I've seen indicate to install the jar to /data/local/tmp/.
我见过的大多数演示都表明将jar安装到/ data / local / tmp /。 I've seen others indicate to try and install it to your sd card (/storage/sdcard0).
我见过其他人指示尝试将其安装到您的SD卡(/ storage / sdcard0)。 After doing that it worked.
这样做之后就有效了。 Seems to be a problem with read permissions.
似乎是读取权限的问题。
我通过使用“ant build”来创建我的jar来解决这个错误。如果你在eclipse中使用export来创建一个jar文件,结果类文件中可能会有一些错误,因此找不到上面的类错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.