Activity used to start app doesn't exist or cannot be launched!

Hi All,
When I start Appium server with Application Path, Package, and Launch Activity selected the server starts with my application and I can run my test. When my test is done I quit the driver.

Next I try to run the same test again with the server already running. I have capabilities written in the TestFixtureSetUp (see below). However, I get the following error:

SetUp : System.InvalidOperationException : A new session could not be created. (Original error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity) (33)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Appium.AppiumDriver…ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at MobileAutomationSample.AndroidSimpleTest.BeforeAll() in AndroidSimpleTest.cs: line 42

=======================================================================

My code:

[TestFixture()]
public class AndroidSimpleTest
{
private AppiumDriver driver;

    [TestFixtureSetUp]
    public void BeforeAll()
    {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.SetCapability("appium-version", "1.2.4.1");
        capabilities.SetCapability("platformName", "Android");
        capabilities.SetCapability("platformVersion", "5.0");
        capabilities.SetCapability("deviceName", "emulator-5554");
        capabilities.SetCapability("browserName", "");
        capabilities.SetCapability("app", "app-debug.apk");
        capabilities.SetCapability("appPackage", "com.company.app");
        capabilities.SetCapability("appActivity", "com.company.app.MainActivity");
        Uri androidUri = new Uri("http://127.0.0.1:4723/wd/hub");
        driver = new AppiumDriver(androidUri, capabilities, TimeSpan.FromSeconds(180));
        driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
        WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
    }

    [TestFixtureTearDown]
    public void AfterAll()
    {
        driver.Quit();
    }

@SergeyTichomirov, you were very helpful last time. Do you by any chance have any suggestions? I upgraded Appium from 1.2.4.1 to 1.3.4.1 and changed emulator from 5.0 API21 to 4.4.2 API19. Capabilities were changed accordingly.

Have you tried something like

capabilities.SetCapability(“appActivity”,“.MainActivity”);

or

capabilities.SetCapability(“appActivity”,“MainActivity”);

?

Sometimes I know something. So why I can’t share information about? :wink:

@SergeyTichomirov, I tried both to no avail. I think it might be the fact that I don’t list path to my app. Where should I store it or how should I reference it? Right now I have it in c:\android\build-tools\19.0.0

Should I write capabilities.SetCapability(“app”, “c:\android\build-tools\19.0.0\app-debug.apk”) ?

Or should the apk file be stored in some particular place? If so, please give me an example of where and how to reference it.

Thank you very much in advance.

Yeah! I am seeng! There should an absolute path like this

I think there is no difference where file is placed. The absolute path should be known.

@SergeyTichomirov,
Worked!!! Didn’t work before, but I think it was because I had 2 or 3 different problems at the same time. Now that I resolved others the absolute path solved this issue. Helps to have someone to bounce stupid ideas off of. Thank you very much for “listening” and all your help/time.

appium.log (37.8 KB)

Hello,

I am also facing the same error.

Please find attached appium log and you can get apk from below link
http://storage.evozi.com/apk/dl/14/10/12/com.google.android.gm.apk?h=bLuDpZa9rqIvjmPcqiJq-w&t=1423563498

Please let me know how to resolve this issue ?

@clmathuriya Can you try manually installing your apk via adb. Then try starting it with

/home/chhagan/android/adt/sdk/platform-tools/adb -s emulator-5554 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.google.android.gm/.ConversationListActivityGoogleMail"

Does it work?

@0x1mason Thanks. It worked :smile:

i am also getting same error i.e App launch activity doesn’t exist or can not be launched … tried with all the above solution but unable to launch my app … need some help on this