简体   繁体   English

当我运行我的Android UIAutomator代码时,它显示错误

[英]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.testing INSTRUMENTATION_RESULT:longMsg = com.android.ui.testing
INSTRUMENTATION_CODE: 0 INSTRUMENTATION_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.

相关问题 登录代码在我的代码中不起作用我已经使用了volly。当我运行应用程序时,它显示错误消息“ Error” - login code is not working in my code i have used volly .when i run application it shows the error message “Error” 如何在Android代码中启动uiautomator? - How can i start the uiautomator in android code? 我想在android中实现SeekBar,但是当我运行以下程序时,我的模拟器显示错误“不幸的是SeekBar已停止” - I want to implement SeekBar in android ,But when i run the below program my emulator shows error that “Unfortunately SeekBar has been stopped” 当我从 Android Studio 在我的 Android 手机上运行我的应用程序时,它显示空白屏幕 - When I run my application on my Android Phone from Android Studio, it shows blank screen 当我运行我的代码时,它会给出错误代码 400,但是当我进行热刷新时,它会在控制台中显示数据,同时从 flutter 中的 api 获取数据 - when i run my code it gives error code 400 but when i do hot refresh it shows data in console while getting data from api in flutter 我应该如何组织我的Android uiautomator测试用例? - How should I organize my Android uiautomator testing case? 当我在模拟器上运行我的代码时出现 ListViewBuilder 问题。 它显示“底部溢出 167 像素” - ListViewBuilder problem when i run my code on emulatior. its shows that "Bottom over flowed by 167 pixels" 运行 uiautomator 时 AccessibilityService 被销毁 - AccessibilityService is Destroyed when uiautomator is run 当我运行我的应用程序时,android 仿真器总是显示空白黑屏 - android emultater always shows a blank black screen when i run my app 在我的 android 应用程序中,字体 Acme 在 xml 中完美显示,但在我运行应用程序时不起作用 - In my android app Font Acme shows perfectly in xml but not working when i run the application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM