1. 程式人生 > >Appium Appium 開發環境搭建 (1)--配置原始碼執行環境

Appium Appium 開發環境搭建 (1)--配置原始碼執行環境

2015/2/25 update:
由於testerhome/appium已更新到最新版本,故把 更新程式碼庫部分移到Q&A中。

 

2015/2/24 update:
把標題改為 Appium開發環境搭建(1)--配置原始碼執行環境,同時微調了格式,以配合後續文章。

之前加入了doctorq的開源專案,今天提前配置一下testerhome/appium的原始碼執行環境。過程中發現有一些地方官方文件沒有提到,在此分享一下配置過程。
PS:這是我的第一個貼子,有些地方寫得不對或不夠清晰請跟貼說明,我會立即更正。

1. 下載程式碼庫

git clone https://github.com/testerhome/appium.git

然後執行此命令時所在的目錄會出現一個appium資料夾。進入資料夾:

cd appium

3. 根據官方介紹配置從原始碼執行appium的環境(ios, android, seledroid)

3.1 執行appium目錄下的reset.sh 進行環境配置。

這個指令碼進行了各個主要執行環境(ios, android, selendroid)的重置和更新,例如下載需要用到的npm包、安裝selendroid等。
如果執行出錯就加上--verbose引數再跑,看是哪裡出錯。

3.2 (僅針對ios)執行sudo ./bin/authorize-ios.js配置ios的認證環境(用來讓ios不認為appium安裝的應用有安全問題)。

$ sudo ./bin/authorize-ios.js
Password:
Enabling DevToolsSecurity
Updating security db for developer access
Granting access to built-in simulator apps
Authorization successful

3.3 使用node .執行appium server:

$ node .
info: Welcome to Appium v1.3.5 (REV 80453f682c18c32377bdf5664533e4df69a62770)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: Console LogLevel: debug

至此,從原始碼執行appium的環境完成了。此時執行的appium就是從原始碼執行的了。如果是debug的話,這樣基本足夠了。但對於開發來說,但這只是配置開發環境的第一步(官方文件裡的Setting up Appium from Source部分),後面還有Hacking on AppiumHacking with Appium for iOSHacking with Appium for Android來配置開發環境,以及Running Tests, Running individual tests來執行測試。後面我會根據官方文件(https://github.com/appium/appium/blob/master/docs/en/contributing-to-appium/appium-from-source.md)配置下去,如果有遇到官方文件內沒有提到的問題,我會另外開貼來幫助大家處理這些問題。

Q&A

更新程式碼庫

$ git fetch git fetch https://github.com/appium/appium.git
git fetch https://github.com/appium/appium.git
remote: Counting objects: 6600, done.
remote: Compressing objects: 100% (2708/2708), done.
remote: Total 6600 (delta 4470), reused 5589 (delta 3679)
Receiving objects: 100% (6600/6600), 15.70 MiB | 260.00 KiB/s, done.
Resolving deltas: 100% (4470/4470), done.
From https://github.com/appium/appium
 * branch            HEAD       -> FETCH_HEAD

$ git checkout master
Warning: you are leaving 1006 commits behind, not connected to
any of your branches:

  80453f6 getting rid of old ci code, use the old-travis-ci branch for reference
  6c8eade Merge pull request #4526 from appium/v1.3.5-branch
  a124a15 clarified garbled changelog text
  634d19b fixed changelog
 ... and 1002 more.

If you want to keep them by creating a new branch, this may be a good time
to do so with:

 git branch new_branch_name 80453f6

Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.


$ git merge FETCH_HEAD
Updating 99794ad..80453f6
Fast-forward
 .gitignore                                         |   21 +-
 .gitmodules                                        |   15 +
 .jscs.json => .jscsrc                              |    8 +-
 .jshintignore                                      |    5 +
 .jshintrc                                          |    2 +-
 .travis.yml                                        |   39 -
 CHANGELOG.txt                                      |  368 ++++-
 CONTRIBUTING.md                                    |  147 +-
 Gruntfile.js                                       |   69 +-
 README.md                                          |   86 +-
 ...
 create mode 100644 test/functional/selendroid/shutdown-specs.js
 create mode 100644 test/functional/selendroid/webview-auto-specs.js
 create mode 100644 test/helpers/sim-udid.js
 create mode 100755 test/tools/prepare-tap.js
 create mode 100644 test/unit/ios-device-specs.js
 create mode 100644 trigger.txt

檢視程式碼庫更新情況:

$ git status
On branch master
Your branch is ahead of 'origin/master' by 1006 commits.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean

注意:這裡的同步僅僅更新了你的原生代碼庫,github上的程式碼庫還是舊的。需要使用git push命令才會把這個變更更新到遠端程式碼庫裡。

執行./reset.sh過程出現的故障及解決方案

  • Error: EACCES, mkdir '/Users/hengjiechen/.npm/gulp-util/3.0.3' ``` $ ./reset.sh --verbose ./reset.sh --verbose ---- Resetting / Initializing Appium ---- RESETTING NPM * Installing new or updated NPM modules (including devDeps) npm ERR! Darwin 14.0.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" "." npm ERR! node v0.10.36 npm ERR! npm v2.3.0 npm ERR! path /Users/hengjiechen/.npm/gulp-util/3.0.3 npm ERR! code EACCES npm ERR! errno 3

npm ERR! Error: EACCES, mkdir '/Users/hengjiechen/.npm/gulp-util/3.0.3'
npm ERR! { [Error: EACCES, mkdir '/Users/hengjiechen/.npm/gulp-util/3.0.3']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/hengjiechen/.npm/gulp-util/3.0.3',
npm ERR! parent: 'appium' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/hengjiechen/Develop/appiumSourceCode/appium/npm-debug.log
---- FAILURE: reset.sh exited with status 1 ----

**原因分析:**之前用管理員許可權安裝過npm,或者某些npm包用了管理員許可權來安裝。這裡千萬不要參照錯誤提示用管理員執行,否則appium就裝不下去了。
**解決方案:**
解除安裝npm,刪除`~/.npm`資料夾(部分目錄沒許可權就用`sudo`來刪),然後用`brew install npm`重新安裝。安裝後再執行`./reset.sh --verbose`(`brew`命令是`homebrew`的命令,提示沒找到命令的請安裝[homebrew]。不能用node官方安裝程式來裝)

*  Warning: Command failed: /bin/sh: mvn: command not found

...
RESETTING SELENDROID

  • Clearing out any old modified server apks
  • Cloning/updating selendroid Submodule 'submodules/selendroid' (https://github.com/selendroid/selendroid.git) registered for path 'submodules/selendroid' Cloning into 'submodules/selendroid'... remote: Counting objects: 16818, done. remote: Compressing objects: 100% (70/70), done. remote: Total 16818 (delta 20), reused 35 (delta 11) Receiving objects: 100% (16818/16818), 13.76 MiB | 304.00 KiB/s, done. Resolving deltas: 100% (7885/7885), done. Checking connectivity... done. Submodule path 'submodules/selendroid': checked out 'ec84567bb60cb2f47936aa4213be7ff537d2e596'
  • Building selendroid server and supporting libraries Running "buildSelendroidServer" task Building selendroid server Getting Selendroid version Selendroid version is 0.13.0 Unable to build selendroid server. Stdout was:

/bin/sh: mvn: command not found

Warning: Command failed: /bin/sh: mvn: command not found
Use --force to continue.

Aborted due to warnings.
---- FAILURE: reset.sh exited with status 1 ----

**原因分析**:沒找到mvn命令。我沒有裝`maven`。
**解決方案**:參考下一個問題,使用以下命令安裝`maven`

brew install homebrew/versions/maven31
sudo ln -s /usr/local/Cellar/maven31/3.1.1 /usr/local/Cellar/maven/
brew switch maven 3.1.1


*  Warning: Command failed: Exception in thread "pool-2-thread-1" java.lang.NoClassDefFoundError: org/eclipse/aether/spi/connector/Transfer$State

...
constituent[38]: file:/usr/local/Cellar/maven/3.2.5/libexec/lib/wagon-http-shared-2.8.jar
constituent[39]: file:/usr/local/Cellar/maven/3.2.5/libexec/lib/wagon-provider-api-2.8.jar

constituent[40]: file:/usr/local/Cellar/maven/3.2.5/libexec/conf/logging/

Exception in thread "pool-2-thread-1" java.lang.NoClassDefFoundError: org/eclipse/aether/spi/connector/Transfer$State
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:608)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
...
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
... 5 more
Use --force to continue.

Aborted due to warnings.
---- FAILURE: reset.sh exited with status 1 ----

**原因分析**:這是安裝Selendroid時出錯了,錯誤資訊表示是找不到class的宣告。這個只能求助google了。
**解決方案**:google後找到<https://github.com/appium/appium/issues/4490>,根據裡面的解決方案使用下面命令修復:

brew install homebrew/versions/maven31
sudo ln -s /usr/local/Cellar/maven31/3.1.1 /usr/local/Cellar/maven/
brew switch maven 3.1.1


*  [ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:generate-sources (default-generate-sources) on project android-driver-app

...
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:generate-sources (default-generate-sources) on project android-driver-app: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:generate-sources failed: Invalid SDK: Platform/API level 16 not available. This command should give you all you need:
[ERROR] /Applications/adt-bundle-mac-x86_64-20140702/sdk/tools/android update sdk --no-ui --obsolete --force
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :android-driver-app

Warning: Command failed: Use --force to continue.

Aborted due to warnings.
---- FAILURE: reset.sh exited with status 1 ----

**原因分析**:大致意思是沒有找到Android sdk裡的`Platform/API level 16`。官方文件提到配置seledroid的話需要用到level 16的API。
**解決方案**:裝上level 16的API。
![](/photo/2015/5676739fe3196bfa8d18de749d7f5778.png)

*  Warning: Command failed: Feb 14, 2015 3:05:20 PM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryExecute

[INFO] Compiling 172 source files to /Users/hengjiechen/Develop/appiumSourceCode/appium/submodules/selendroid/selendroid-server/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:

The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
...
INFO: Retrying request
Feb 14, 2015 3:05:20 PM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request

Warning: Command failed: Feb 14, 2015 3:05:20 PM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Connection reset
Feb 14, 2015 3:05:20 PM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Connection reset
Feb 14, 2015 3:05:20 PM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Feb 14, 2015 3:05:20 PM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Use --force to continue.

Aborted due to warnings.
---- FAILURE: reset.sh exited with status 1 ----

**原因分析**:這個原因應該是編譯器暫存空間不足導致的(StackOverflowError)。
**解決方案**:執行下面的命令加大暫存空間:

export MAVEN_OPTS="-Xms1024m -Xmx2048m -Xss2048k"

相關推薦

Appium Appium 開發環境搭建 (1)--配置原始碼執行環境

2015/2/25 update: 由於testerhome/appium已更新到最新版本,故把 更新程式碼庫部分移到Q&A中。   2015/2/24 update: 把標題改為 Appium開發環境搭建(1)--配置原始碼執行環境,同時微調了格式,以配合

webpack+react+es2015輕鬆環境搭建配置執行專案

簡介: webpack:是近期最火的一款模組載入器兼打包工具,它能把各種資源,例如JS(含JSX)、coffee、樣式(含less/sass)、圖片等都作為模組來使用和處理。 react:現在最熱門的前端框架,毫無疑問是 React 。 es2015:ECMAScript 6。       以上是她們的基

Appium環境搭建配置

一、安裝Nodejs 下載後,雙擊安裝檔案,按提示來安裝。 測試安裝是否成功:執行cmd,輸入node –v 二、安裝android的SDK 安裝時記下安裝目錄,如下圖: 1.     選中 計算機->右鍵選屬性->高階系統設定->高階->環境變數,逐層進入環境變數介面。

RobotFramework(RF)+Appium完全安裝環境搭建配置的解決方案

【本部落格原創,都是經過博主本人全程操作安裝過的,踩過的坑都記錄在本文,有興趣的讀者跟著做一遍~~~】一、搭建環境流程1.先安裝python2.7環境(python-2.7.14.amd64.msi),(1)再安裝第三方庫:wxPython(32位的電腦就安裝win32,64

BeeGFS開發環境搭建1-環境配置

BeeGFS常用於高效能運算中的分散式檔案儲存,其對巨量小檔案的支援相比於其他大多數檔案系統而言,要好太多,這裡介紹搭建的詳細過程

C | C++ 環境搭建 1.Visual Studio 開發環境搭建

visual 環境搭建 studio C | C++ 是我們初級入門的計算機語言之一,現階段用vs環境搭建 第一步: 下載vs軟件,並安裝vs和其幫助軟件MSDN。 在微軟官網下載,或者其他資源。其軟件缺點非開源軟件目前在Win系統搭建。C |

Android 開發:(一)安卓開發環境搭建配置 (Windows和Mac )以及目錄結構介紹

(一)、windows版 一. 開發工具: 1.Android Studio:(http://www.androiddevtools.cn/) 2.Genymotion(虛擬機器):(http://www.genymotion.net/) (二)、Mac版 一

PHP開發環境搭建一:PHP整合環境XAMPP的安裝與配置

1. XMAPP簡介       XAMPP(Apache+MySQL/MariaDB+PHP+Perl)開頭的X代表X-OS,代表可以在任何常見作業系統下使用,包括Windows、Mac、Linux,開源平臺。 XAMPP(Apache+MySQL+PHP+PERL)是一個

PHP開發環境搭建一:PHP整合環境XAMPP 的安裝與配置

1. XMAPP簡介       XAMPP(Apache+MySQL/MariaDB+PHP+Perl)開頭的X代表X-OS,代表可以在任何常見作業系統下使用,包括Windows、Mac、Linux,開源平臺。 XAMPP(Apache+MySQL+PHP+PERL)是一個

PHP開發搭建環境二:開發工具PhpStorm安裝、啟用以及配置 PHP開發環境搭建一:PHP整合環境XAMPP 的安裝與配置

  關於php的開發工具很多,目前市面上最好用最強大的莫過於PhpStorm這款開發神器了,但是鑑於很多開發者朋友在網站上下載的PhpStorm開發工具不能用,或者使用起來很不方便,筆者把最好用的下載地址及免費啟用教程共享出來。 一、安裝並配置整合環境XAMPP 具體可以參考我的這篇部落格:P

Php開發環境搭建(1)-mysql

1. 安裝mysql,mysql-5.7.23-winx64.zip ,地址在我的雲盤,官網下載mysql,壓縮包版本,之後解壓到電腦的硬碟中   直接進行解壓。 2.解壓完成後,在解壓目錄建立 my.ini檔案,並配置 [mysqld] # set basedir t

Hadoop原始碼閱讀環境搭建(IDEA) Hadoop原始碼編譯環境搭建 IDEA配置maven中央庫

拿到一份Hadoop原始碼之後,經常關注的兩件事情就是 1、怎麼閱讀?涉及IDEA和Eclipse工程搭建。IDEA搭建,選擇原始碼,逐步匯入即可;Eclipse可以選擇後臺生成工程,也可以選擇IDE匯入。二者工程也可以互相匯入\到處。 2、怎麼構建?利用maven,生成安裝包。 二者均需配置maven

PHP開發環境搭建之一:PHP整合環境XAMPP 的安裝與配置

1. XMAPP簡介 XAMPP(Apache+MySQL/MariaDB+PHP+Perl)    開頭的X代表X-OS,代表可以在任何常見作業系統下使用,包括Windows、Mac、Linux,開源平臺。 XAMPP(Apache+MySQL+PHP+PERL)是一

Swift3.0服務端開發(一) 完整示例概述及Perfect環境搭建配置(服務端+iOS端)

本篇部落格算是一個開頭,接下來會持續更新使用Swift3.0開發服務端相關的部落格。當然,我們使用目前使用Swift開發服務端較為成熟的框架Perfect來實現。Perfect框架是加拿大一個創業團隊開發的,目前是Perfect2.0版本,關於Perfect框架,下方會詳細的介紹。本篇部落格會演示一個完整的D

cesium學習1--環境搭建配置

本文討論如何配置學習環境 預期目的:在webstrom中配置好開發環境,並執行達到下圖效果 1)nodejs環境配置 很簡單直接下載nodejs安裝檔案安裝即可。 備註:由於node的資源在國內被牆的厲害,推薦採用cnpm替代npm來安裝一些依賴庫

Hadoop2.7.1+Hbase1.2.1叢集環境搭建(1)hadoop2.7.1原始碼編譯

        官網目前提供的下載包為32位系統的安裝包,在linux 64位系統下安裝後會一直提示錯誤“WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-j

【Flutter 系列——1】Flutter環境搭建配置這一篇就夠了(Windows)

最近正式入坑Flutter,首先從環境搭建開始,看了網上好多關於Windows環境搭建的資料,基本都是按官方文件寫的,看完的感受是,還不如直接去看官方文件。 本文主要總結我實際搭建的過程,最後發現不一定按網上那些部落格或者官方文件寫的來也可以搭建成功。 總的來說需要的

Appium的ios環境搭建、真機執行app

之前沒用過蘋果系統,在搭建appium過程中,基本命令都是百度來的,如果你在其中遇到了撓頭的問題,不要急躁,慢慢來,一定會成功的。 由於開始並沒有做文件積累,所以寫的不會很全面。有問題請留言,大家一起交流。 首先感謝IOS開發同學無私的幫助 一.環境及版本: xcode

Mac虛擬機器裡Python+Appium環境搭建Android真機執行

建立MacBook虛擬機器就不多說了,網上很多資源。拷貝來的MacBook Virtual Machine需要先做以下步驟才可以使用:1. 安裝VMware122. 解壓unlocker-206,找到win-install.cmd並且run as administrato

Ubuntu14下Hadoop開發&lt;1&gt; 基礎環境安裝

oot jar包 臺式機 解壓 span ice href 安裝samba lan 準備了一臺淘汰的筆記本。單核CPU。3G內存。160G硬盤;準備一個2G的U盤在官網下載了64位的14.04版本號(麒麟)的ISO。下載UNetbootin(Ubuntu專用U盤安裝工