51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1835|回复: 5
打印 上一主题 下一主题

[Appium] appium java中报错

[复制链接]
  • TA的每日心情
    奋斗
    2016-12-1 14:05
  • 签到天数: 29 天

    连续签到: 1 天

    [LV.4]测试营长

    跳转到指定楼层
    1#
    发表于 2016-3-21 15:25:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    > 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
    >
    怎么解决?求助
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    无聊
    2016-8-18 09:20
  • 签到天数: 3 天

    连续签到: 1 天

    [LV.2]测试排长

    2#
    发表于 2016-3-21 16:54:05 | 只看该作者
    检查APK包的路劲 名称 有没有编写正确,错误是远程安装失败
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    2016-12-1 14:05
  • 签到天数: 29 天

    连续签到: 1 天

    [LV.4]测试营长

    3#
     楼主| 发表于 2016-3-22 13:47:05 | 只看该作者
    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();
         }
    }



    烦请看看哪里出问题了

    回复 支持 反对

    使用道具 举报

    该用户从未签到

    4#
    发表于 2016-10-31 17:56:39 | 只看该作者
    謝謝,希望以後多些
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    5#
    发表于 2016-11-28 07:07:43 | 只看该作者
    好好看看,非常好的帖子
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-23 12:17 , Processed in 0.066757 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表