51Testing软件测试论坛

标题: appium java中报错 [打印本页]

作者: lxp5589425    时间: 2016-3-21 15:25
标题: appium java中报错
> Launching Appium server with command: D:\BaiduYunDownload\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --app D:\BaiduYunDownload\ContactManager.apk --platform-name Android --platform-version 19 --automation-name Appium --device-name "Coolpad 5952" --log-no-color
> info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"app":"D:\\BaiduYunDownload\\ContactManager.apk","address":"127.0.0.1","logNoColors":true,"deviceName":"Coolpad 5952","platformName":"Android","platformVersion":"19","automationName":"Appium"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"F:\\andriodproject\\AppLogin\\apps\\glvip20160317beta.apk","platformVersion":"4.3","deviceName":"Coolpad 5952","platformName":"Android","appActivity":".glvip20160317beta","browserName":"","appPackage":"com.example.android.glvip20160317beta"}}
> info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
> info: [debug] Using local app from desired caps: F:\andriodproject\AppLogin\apps\glvip20160317beta.apk
> info: [debug] Creating new appium session 5845154b-da26-44b0-8d16-fe13b88de72f
> info: Starting android appium
> info: [debug] Getting Java version
> info: Java version is: 1.6.0
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Checking whether app is actually present
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe devices
> info: [debug] 1 device(s) connected
> info: Found device c1c6562
> info: [debug] Setting device id to c1c6562
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 wait-for-device
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "echo 'ready'"
> info: [debug] Starting logcat capture
> info: [debug] Getting device API level
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 18
> info: Device API level is: 18
> info: [debug] Extracting strings for language: default
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "getprop persist.sys.language"
> info: [debug] Current device persist.sys.language: zh
> info: [debug] java -jar "D:\BaiduYunDownload\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools_1.6.jar" "stringsFromApk" "F:\andriodproject\AppLogin\apps\glvip20160317beta.apk" "C:\Users\ADMINI~1\AppData\Local\Temp\com.example.android.glvip20160317beta" zh
> info: [debug] No strings.xml for language 'zh', getting default strings.xml
> info: [debug] java -jar "D:\BaiduYunDownload\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools_1.6.jar" "stringsFromApk" "F:\andriodproject\AppLogin\apps\glvip20160317beta.apk" "C:\Users\ADMINI~1\AppData\Local\Temp\com.example.android.glvip20160317beta"
> warn: Error getting strings.xml from apk
> info: [debug] Exception in thread "main" brut.androlib.AndrolibException: Could not decode arsc file
>         at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:54)
>         at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:540)
>         at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:76)
>         at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:68)
>         at io.appium.apktools.StringsXML.run(StringsXML.java:84)
>         at io.appium.apktools.Main.main(Main.java:31)
> Caused by: java.io.IOException: Expected: 0x001c0001, got: 0x00000000
>         at brut.util.ExtDataInput.skipCheckInt(ExtDataInput.java:48)
>         at brut.androlib.res.decoder.StringBlock.read(StringBlock.java:43)
>         at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:100)
>         at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:81)
>         at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49)
>         ... 5 more
>
> warn: Could not get strings, continuing anyway
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "echo '{}' > /data/local/tmp/strings.json"
> info: [debug] Checking whether aapt is present
> info: [debug] Using aapt from D:\BaiduYunDownload\sdk\sdk\build-tools\android-4.4\aapt.exe
> info: [debug] Retrieving process from manifest.
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\build-tools\android-4.4\aapt.exe dump xmltree F:\andriodproject\AppLogin\apps\glvip20160317beta.apk AndroidManifest.xml
> info: [debug] Set app process to: com.example.android.glvip20160317beta
> info: [debug] Not uninstalling app since server not started with --full-reset
> info: [debug] Checking app cert for F:\andriodproject\AppLogin\apps\glvip20160317beta.apk.
> info: [debug] executing cmd: java -jar D:\BaiduYunDownload\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar F:\andriodproject\AppLogin\apps\glvip20160317beta.apk
> info: [debug] App not signed with debug cert.
> info: [debug] Resigning apk.
> info: [debug] executing cmd: java -jar D:\BaiduYunDownload\Appium\node_modules\appium\node_modules\appium-adb\jars\sign.jar F:\andriodproject\AppLogin\apps\glvip20160317beta.apk --override
> info: [debug] Zip-aligning F:\andriodproject\AppLogin\apps\glvip20160317beta.apk
> info: [debug] Checking whether zipalign is present
> info: [debug] Using zipalign from D:\BaiduYunDownload\sdk\sdk\tools\zipalign.exe
> info: [debug] Zip-aligning apk.
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\tools\zipalign.exe -f 4 F:\andriodproject\AppLogin\apps\glvip20160317beta.apk C:\Users\ADMINI~1\AppData\Local\Temp\116221-5776-1jufk1r\appium.tmp
> info: [debug] MD5 for app is c60364d78e47cc740796791b468ff7cb
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "ls /data/local/tmp/c60364d78e47cc740796791b468ff7cb.apk"
> info: [debug] Getting install status for com.example.android.glvip20160317beta
> info: [debug] Getting device API level
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 18
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "pm list packages -3 com.example.android.glvip20160317beta"
> info: [debug] App is not installed
> info: Installing App
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "mkdir -p /data/local/tmp/"
> info: [debug] Removing any old apks
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "ls /data/local/tmp/*.apk"
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell rm "/data/local/tmp/635eb4912b1b11c520eab2d2b6a11ea4.apk"
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 push "F:\\andriodproject\\AppLogin\\apps\\glvip20160317beta.apk" /data/local/tmp/c60364d78e47cc740796791b468ff7cb.apk
> info: [debug] Uninstalling com.example.android.glvip20160317beta
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "am force-stop com.example.android.glvip20160317beta"
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 uninstall com.example.android.glvip20160317beta
> info: [debug] App was not uninstalled, maybe it wasn't on device?
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "pm install -r /data/local/tmp/c60364d78e47cc740796791b468ff7cb.apk"
> warn: Installing remote apk failed, going to uninstall and try again
> info: [debug] Removing any old apks
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "ls /data/local/tmp/*.apk"
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell rm "/data/local/tmp/c60364d78e47cc740796791b468ff7cb.apk"
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 push "F:\\andriodproject\\AppLogin\\apps\\glvip20160317beta.apk" /data/local/tmp/c60364d78e47cc740796791b468ff7cb.apk
> info: [debug] Attempting to install again for the last time
> info: [debug] executing cmd: D:\BaiduYunDownload\sdk\sdk\platform-tools\adb.exe -s c1c6562 shell "pm install -r /data/local/tmp/c60364d78e47cc740796791b468ff7cb.apk"
> info: [debug] Stopping logcat capture
> info: [debug] Logcat terminated with code null, signal SIGTERM
> info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
> warn: UiAutomator did not shut down fast enough, calling it gone
> info: [debug] Cleaning up android objects
> info: [debug] Cleaning up appium session
> error: Failed to start an Appium session, err was: Error: Remote install failed: pkg: /data/local/tmp/c60364d78e47cc740796791b468ff7cb.apk

> Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]
> info: [debug] Error: Remote install failed: pkg: /data/local/tmp/c60364d78e47cc740796791b468ff7cb.apk
报错> error: Failed to start an Appium session, err was: Error: Remote install failed: pkg: /data/local/tmp/c60364d78e47cc740796791b468ff7cb.apk
>
怎么解决?求助
作者: lin0731032    时间: 2016-3-21 16:54
检查APK包的路劲 名称 有没有编写正确,错误是远程安装失败
作者: lxp5589425    时间: 2016-3-22 13:47
lin0731032 发表于 2016-3-21 16:54
检查APK包的路劲 名称 有没有编写正确,错误是远程安装失败

有apk的包,在apps目录的下面;代码如下:
package com.logingl.demo;
import io.appium.java_client.AppiumDriver;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.io.File;  
import java.net.URL;  
import java.util.List;

  
public class glvipbeta {
     private AppiumDriver driver;
    @Before
     public void setUp() throws Exception {
            //设置apk的路径
         File classpathRoot = new File(System.getProperty("user.dir"));
         File appDir = new File(classpathRoot, "apps");
         File app = new File(appDir, "glvip20160317beta.apk");
                 //设置自动化相关参数
         DesiredCapabilities capabilities = new DesiredCapabilities();
         capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("platformName", "Android");
         capabilities.setCapability("deviceName", "Coolpad 5952");
         
         //设置安卓系统版本
         capabilities.setCapability("platformVersion", "4.3");
         //设置apk路径
         capabilities.setCapability("app", app.getAbsolutePath());      
         //设置app的主包名和主类名
         capabilities.setCapability("appPackage", "com.example.android.glvip20160317beta");
        capabilities.setCapability("appActivity", ".glvip20160317beta");
         
         //初始化
        driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);      
     }
  
     @Test
     public void addContact(){
         WebElement el = driver.findElement(By.name("App to the happy life of the client"));
         el.click();
         List<WebElement> buttonList = driver.findElementsByClassName("button");
         buttonList.get(0).sendKeys("我的");
         buttonList.get(1).sendKeys("设置");
         buttonList.get(2).sendKeys("修改密码");
         List<WebElement> textFieldsList = driver.findElementsByClassName("textfield");
         textFieldsList.get(0).sendKeys("558942");
         textFieldsList.get(1).sendKeys("196532");
         textFieldsList.get(2).sendKeys("196532");
         driver.findElementByName("Save").click();
     }   
   
    @After
     public void tearDown() throws Exception {
         driver.quit();
     }
}



烦请看看哪里出问题了


作者: 海里的幸福    时间: 2016-10-31 17:56
謝謝,希望以後多些
作者: 给俄滚    时间: 2016-11-28 07:07
好好看看,非常好的帖子




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2