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

grep · June 08, 2019 · Last by wyli2019 replied at June 11, 2019 · 627 hits

在使用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

请教下这是什么情况

共收到 9 条回复 时间 点赞

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

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

确定最后没少打字?

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

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

grep · #5 · June 10, 2019 作者
Author only
grep · #6 · June 10, 2019 作者
Author only
grep · #7 · June 10, 2019 作者
Author only
grep · #8 · June 10, 2019 作者
Author only

换成绝对路径试试

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up