Question

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.

Was it helpful?

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.

OTHER TIPS

Check package name in .java or .kt in the respective app is same as in XML package name.

for example : XML - tools:context="com.example.emptyname.MainActivity" kt - package com.example.emptyname

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");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top