Search code examples
androidselenium-webdriverappium

Activity used to start app doesn't exist! Make sure it exists


When I try using Appium to test my Hello World Android app, I get Activity used to start app doesn't exist! Make sure it exists

  1. I have an apk with a package in it: com.company.myapp
  2. The package has an activity in it: MainActivity
  3. The apk targets Android 4.4, API level 19
  4. I have a simulated Android device via adt-bundle-mac-x86_64-20131030/sdk/tools/emulator -avd 4.4-KitKat-Nexus-4
  5. In DesiredCapabilities, I've tried the following for app-activity:
    1. "MainActivity"
    2. ".MainActivity"
    3. "com.company.myapp.MainActivity"
  6. Appium's log says 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"}}
  7. Appium creates a session, starts android appium, finds my connected (simulated) device, says App is not installed, App already signed, finds an apk it wants to keep, can't find any to remove, runs adb -s emulator-5554 shell pm install -r [apk it found that it wants to keep], forwards port 4724, wakes up device getting {"value":true,"status":0}, ensures screen is unlocked ...

And then it executes adb -s emulator-5554 shell am start -n com.company.myapp/com.company.myapp.MainActivity and gives the error message above.

It also tries with . prepended to activity and gives the same error message.


Solution

  • I discovered that if the app was installed prior to running my test, it didn't complain about the Activity being absent.

    And if I launch appium with appium --full-reset it uninstalls the existing app and then installs some apk and finds the Activity.