用于启动应用程序的活动不存在!确保它存在

时间:2013-12-02 18:33:27

标签: android selenium-webdriver appium

当我尝试使用Appium测试我的Hello World Android应用时,我得到Activity used to start app doesn't exist! Make sure it exists

  1. 我有一个带有包的apk:com.company.myapp
  2. 该程序包中包含一项活动:MainActivity
  3. apk定位Android 4.4,API等级19
  4. 我通过adt-bundle-mac-x86_64-20131030/sdk/tools/emulator -avd 4.4-KitKat-Nexus-4
  5. 创建了一个模拟Android设备
  6. 在DesiredCapabilities中,我为app-activity尝试了以下内容:
    1. "MainActivity"
    2. ".MainActivity"
    3. "com.company.myapp.MainActivity"
  7. Appium的日志显示debug: Request received with params: {"desiredCapabilities":{"newCommandTimeout":"60","app":"/Users/me/Development/workspace/myapp/bin/myapp.apk","platform":"MAC","browserName":"","app-package":"com.company.myapp","device-ready-timeout":"60","device":"android","launch":"true","compressXml":"true","app-wait-activity":"com.company.myapp.MainActivity","app-activity":"com.company.myapp.MainActivity","version":"4.4"}}
  8. Appium创建一个会话,启动android appium,找到我的连接(模拟)设备,说App没有安装,App已经签名,发现它想要保留的apk,找不到任何要删除的,运行{{1转发端口adb -s emulator-5554 shell pm install -r [apk it found that it wants to keep],唤醒设备获取4724,确保屏幕解锁...
  9. 然后它执行{"value":true,"status":0}并给出上面的错误消息。

    它也尝试。前置于活动并给出相同的错误消息。

3 个答案:

答案 0 :(得分:2)

我发现如果应用程序已安装之前来运行我的测试,则不会抱怨该活动缺席。

如果我使用appium --full-reset启动appium,它会卸载现有应用,然后安装一些 apk并找到活动。

答案 1 :(得分:1)

检查相应应用程序中 .java 或 .kt 中的包名称是否与 XML 包名称中的相同。

例如: XML - 工具:上下文=“com.example.emptyname.MainActivity” kt - 包 com.example.emptyname

答案 2 :(得分:0)

Does not clear the app data and launch the app from the desire activity      
DesiredCapabilities capabilities = new DesiredCapabilities();
     capabilities.setCapability("deviceName","Galaxy E7");
                   capabilities.setCapability("platformName", "Android");
                   capabilities.setCapability("version", "5.1.1");
                 capabilities.setCapability("noReset", true);
                 capabilities.setCapability("fullReset", false);
               capabilities.setCapability("app", "D:/Builds/RSQuare_Live.apk");
                 capabilities.setCapability("app-wait-activity", "com.rr.consultants.base.SpalshScreenActivity");