adb shell pm list packages:列出所有的包名。
adb shell dumpsys package:列出所有的安裝應用的信息
dumpsys package com.android.XXX:查看某個包的具體信息
如何查看app的包名和Activity
解決辦法:
a.有源碼的情況,找到AndroidManifest.xml,找到android.intent.category.LAUNCHER關鍵字,就能找到需要的Activity
包名在這里看;<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.chnMicro.MFExchange"
一般位於XML定義的下一行,搜索“package”就能找到
b.沒有源碼的情況,鏈接好手機——cmd下輸入adb logcat>D:log.txt——運行被測app——Ctrl+c停止,去D盤打開log文件搜索“LauncherAppInfo”就能在其后找到Activity
from http://www.51testing.com/html/01/610901-864955.html
A new session could not be created 看到這個錯誤 往上翻error
在版本升級后問題解決,猜測是服務被重啟了。
但出現新的問題:urllib2.URLError: <urlopen error [Errno 10061] >
解決辦法:webdriver.Remote('http://localhost:4733/wd/hub', desired_caps)
標紅的地方要和appium設置里的一致

目前代碼:
#coding:utf-8
from appium import webdriver
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.1.2'
desired_caps['deviceName'] = 'YT9108NYVV'
desired_caps['appPackage'] = 'com.android.calculator2'
desired_caps['appActivity'] = '.Calculator'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.find_element_by_name("1").click()
目前存在的問題:
運行無反應。
log:
> info: [debug] Starting logcat capture
> error: Logcat capture failed: spawn ENOENT
> info: [debug] Stopping logcat capture
采取操作:sdk的路徑全移動到不帶空格的目錄下,並修改系統變量和path里面的路徑。
目前log:
error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.
> info: Device API level is: 16
解決辦法:
appium目前支持最低的api為17.
所以只能刷機到更高一點的版本來進行適配。
