Appium 使用 python+appium 在模拟器自动安装 apk 包提示不能开始程序

左撇子的菜鸟 · 2019年06月08日 · 最后由 左撇子的菜鸟 回复于 2019年08月08日 · 1586 次阅读

在使用 python+appium 自动安装 apk 安装包时已经安装成功,但提示不能开始程序
下面是我的代码:
from appium import webdriver
import os

# 提取安装包根路径
apk_path = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(file)),'..'))
appPath = lambda x:os.path.join(apk_path,'x7sy\app',x)

caps = {}
caps["platformName"] = "Android"
caps["platformVersion"] = "5.1.1"
caps["deviceName"] = "127.0.0.1:5555"
caps["app"] = appPath('安装包')
caps["appPackage"] = "包名"
caps["appActivity"] = "包名.activity.MainActivit"
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)

下面是运行代码后的报错:
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot start the '包名' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Cannot start the '包名' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Activity name '.包名.activity.MainActivit' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity

请教下这是什么情况

共收到 11 条回复 时间 点赞

你的包名就是叫 “包名”? 确定这是对的吗?

caps["appActivity"] = "包名.activity.MainActivit" .  

确定最后没少打字?

通常是 appActivity 设置有问题,不要随便写,可以 adb 抓包看启动 APP 时最先创建的 activity

aapt d badging $apk_path
解析一下这个包,获取真实的 package name 和 launchable-activity,不要乱写参数进去.

僅樓主可見
僅樓主可見
僅樓主可見
僅樓主可見

换成绝对路径试试

请问楼主这个问题解决了吗,我也遇到了

尐玹丶 回复

我的是 appActivity 有问题,你可以问下开发,你们产品的 appActivity

需要 登录 後方可回應,如果你還沒有帳號按這裡 注册