Appium 不管是用 exe 还是直接用命令启动 Appium 时,总报这个乱码

巫妖 · 2014年05月03日 · 最后由 strive 回复于 2016年03月28日 · 1143 次阅读

各位好:
我在网上收罗了下说 Error getting strings.xml from apk 是代表 APK 有问题,但我单独安装是正常的。
我使用了命令启动 APPIUM 或者用 exe 执行 appium 都报类似错误。我使用的是 Appium v1.0.0
那乱码是咋个回事呢????
麻烦各位提提意见,谢谢你们!!!

————————————————————————
Eclipse 中报错如下:

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: 'java' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 12.29 seconds
Build info: version: '2.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39'
System info: host: 'dell', ip: '192.168.2.162', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.7.0_17'
Driver info: com.test.appium.AndroidTest$SwipeableWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at com.test.appium.AndroidTest$SwipeableWebDriver.(AndroidTest.java:62)
at com.test.appium.AndroidTest.setUp(AndroidTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

java.lang.NullPointerException
at com.test.appium.AndroidTest.tearDown(AndroidTest.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

——————————————————————
我的代码:
@Before
public void setUp() throws Exception {
// set up appium
final File classpathRoot = new File(System.getProperty("user.dir"));
final File appDir = new File(classpathRoot, "/apps/ContactManager");
final File app = new File(appDir, "ContactManager.apk");
final DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device", "Android");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability(CapabilityType.VERSION, "4.2.2");
capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.example.android.contactmanager");
capabilities.setCapability("appActivity", ".ContactManager");
driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

————————————————————

Microsoft Windows 版本 6.3.9600 2013 Microsoft Corporation。保留所有权利。

C:\Users\win8>appium-doctor
Running Android Checks
✔ ANDROID_HOME is set to "F:\AndroidAndJDK\sdk"
✔ JAVA_HOME is set to "D:\Program Files\Java\jdk1.7.0_17."
✔ ADB exists at F:\AndroidAndJDK\sdk\platform-tools\adb.exe
✔ Android exists at F:\AndroidAndJDK\sdk\tools\android.bat
✔ Emulator exists at F:\AndroidAndJDK\sdk\tools\emulator.exe
✔ Android Checks were successful.

✔ All Checks were successful

Microsoft Windows 版本 6.3.9600 2013 Microsoft Corporation。保留所有权利。

C:\Users\win8>appium -a 127.0.0.1 -p4723 -U emulator-5554
info: Welcome to Appium v1.0.0 (REV f0a00fab2335fa88cb355ab4dc43a9cd3f3236c0)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: socket.io started
info: Non-default server args: {"udid":"emulator-5554","address":"127.0.0.1"}
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"desiredCapabilities":{"platform":"WINDOWS
","app":"E:\NeseTest\DolphinTest\DolphinTest-web\apps\ContactManager\Conta
ctManager.apk","browserName":"","appActivity":".ContactManager","device":"Androi
d","appPackage":"com.example.android.contactmanager","version":"4.2.2"}}
info: Using local app from desired caps: E:\NeseTest\DolphinTest\DolphinTest-web
\apps\ContactManager\ContactManager.apk
info: Creating new appium session 9057d89b-faae-4059-ab6f-b657528d2a97
info: Starting android appium
debug: Using fast reset? true
info: Preparing device for session
info: Checking whether app is actually present
info: Checking whether adb is present
info: [ADB] Using adb from F:\AndroidAndJDK\sdk\platform-tools\adb.exe
info: Trying to find a connected android device
info: [ADB] Getting connected devices...
debug: executing: "F:\AndroidAndJDK\sdk\platform-tools\adb.exe" devices
info: [ADB] 1 device(s) connected
info: Setting device id to emulator-5554
info: [ADB] Waiting for device to be ready and to respond to shell commands (tim
eout = 5)
debug: executing: "F:\AndroidAndJDK\sdk\platform-tools\adb.exe" -s emulator-5554
wait-for-device
debug: executing: "F:\AndroidAndJDK\sdk\platform-tools\adb.exe" -s emulator-5554
shell "echo 'ready'"
info: Starting logcat capture
info: Getting device API level
debug: executing: "F:\AndroidAndJDK\sdk\platform-tools\adb.exe" -s emulator-5554
shell "getprop ro.build.version.sdk"
info: Device is at API Level 17
debug: java -jar "C:\Users\win8\AppData\Roaming\npm\node_modules\appium\lib\devi
ces\android\helpers\strings_from_apk.jar" "E:\NeseTest\DolphinTest\DolphinTest-w
eb\apps\ContactManager\ContactManager.apk" "C:\Windows\Temp\com.example.android.
contactmanager"
warn: Error getting strings.xml from apk
debug: 'java' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���

debug: executing: "F:\AndroidAndJDK\sdk\platform-tools\adb.exe" -s emulator-5554
shell "echo '{}' > C:\data\local\tmp\strings.json"
info: Checking whether aapt is present
debug: Set app process to: .contactmanager
debug: Not uninstalling app since server not started with --full-reset
debug: Checking app cert for E:\NeseTest\DolphinTest\DolphinTest-web\apps\Contac
tManager\ContactManager.apk: java -jar "C:\Users\win8\AppData\Roaming\npm\node_m
odules\appium\lib\devices\android\helpers\verify.jar" "E:\NeseTest\DolphinTest\D
olphinTest-web\apps\ContactManager\ContactManager.apk"
debug: App not signed with debug cert.
debug: Resigning apk with: java -jar "C:\Users\win8\AppData\Roaming\npm\node_mod
ules\appium\lib\devices\android\helpers\sign.jar" "E:\NeseTest\DolphinTest\Dolph
inTest-web\apps\ContactManager\ContactManager.apk" --override
info: Stopping logcat capture
debug: Logcat terminated with code null, signal SIGTERM
info: Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
info: Cleaning up android objects
info: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Command failed: 'java'
�����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���

info: Error: Command failed: 'java' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���

at ChildProcess.exithandler (child_process.js:637:15)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
info: Responding to client with error: {"status":33,"value":{"message":"A new se
ssion could not be created. (Original error: Command failed: 'java' �����ڲ����ⲿ�
��Ҳ���ǿ����еij���\r\n���������ļ���\r\n)","killed":false,"code":1,"signal":null
,"origValue":"Command failed: 'java' �����ڲ����ⲿ���Ҳ���ǿ����еij���\r\n��������
�ļ���\r\n"},"sessionId":null}
POST /wd/hub/session 500 8070ms - 508b

共收到 5 条回复 时间 点赞

先改下 cmd 出口的编码看看,chcp 65001 ,还显示乱码就 属性 - 字体,设为 Lucida Console

跟你的终端有关, 自己修改下编码就可以了.

to xuxu :感谢,乱码问题确实解决了,明白了错误的大概问题
to seveniruby:谢谢,该问题已经解决,我把 appium 放入我们自己的框架,引入的 jar 包比较多,有些冲突。
再次感谢两位的回复。

我也碰到乱码了,请问哪里可以设置!

我也碰到乱码了,这个应该怎么解决呀!!

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册