How can I start test without apk on my pc?

Hi!
How I can start my test without apk-file on my pc?

I try set capabilities

private DesiredCapabilities setSessionParams(){
    DesiredCapabilities dc = new DesiredCapabilities();
    dc.setCapability("platformName",platformName);
    dc.setCapability("deviceName", deviceName);
    dc.setCapability("fullReset", false);
    dc.setCapability("noReset", true);
    dc.setCapability("appPackage", packageName); //com.example.app
    dc.setCapability("appActivity", activityName); //.MainActivity or MainActivity
    dc.setCapability("udid", udid);
    dc.setCapability("platformVersion", platformVersion);
    return dc;
}

public AndroidDriver loadApp(){
    AndroidDriver driver = null;
    try {
        driver = new AndroidDriver(new URL("http://" + host + ":" + port + "/wd/hub"),
                setSessionParams());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    return driver;
}

But in appium log i can see

[MJSONWP] Encountered internal error running command: Error: Cannot start the 'com.example.app' application. Original error: Activity name '.MainActivity' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity
[MJSONWP]     at ADB.callee$0$0$ (C:\Users\xxx\appium-desktop\app-1.6.2\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:125:11)
[MJSONWP]     at tryCatch (C:\Users\xxx\appium-desktop\app-1.6.2\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[MJSONWP]     at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\xxx\appium-desktop\app-1.6.2\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[MJSONWP]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\xxx\appium-desktop\app-1.6.2\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[MJSONWP]     at GeneratorFunctionPrototype.invoke (C:\Users\xxx\appium-desktop\app-1.6.2\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)

If I add absolute path like

dc.setCapability("app", "absolute path");

to my capabilities I see in appium log

[MJSONWP] Encountered internal error running command: Error: Cannot start the 'com.example.app' application. Original error: Activity name '.MainActivity' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity
[MJSONWP]     at ADB.callee$0$0$ (C:\Users\xxx\appium-desktop\app-1.6.2\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:125:11)
[MJSONWP]     at tryCatch (C:\Users\xxx\appium-desktop\app-1.6.2\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[MJSONWP]     at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\xxx\appium-desktop\app-1.6.2\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[MJSONWP]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\xxx\appium-desktop\app-1.6.2\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[MJSONWP]     at GeneratorFunctionPrototype.invoke (C:\Users\xxx\appium-desktop\app-1.6.2\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)

If i delete appPackage & activity capability like

DesiredCapabilities dc = new DesiredCapabilities();
    dc.setCapability("platformName",platformName);
    dc.setCapability("deviceName", deviceName);
    dc.setCapability("fullReset", false);
    dc.setCapability("noReset", true);
    dc.setCapability("udid", udid);
    dc.setCapability("platformVersion", platformVersion);
    dc.setCapability("app", appPath);

my test working.

I have always used a path to a local APK in my Appium testing so I am by no means an expert here but… It looks like the revolves around finding the MainActivity in your app. Are you absolutely sure that the app’s launch activity is actually called MainActivity? Its kinda rare but I have seen Android apps that dont launch an activity called MainActivity and instaed use something like “HomeActivity”. I would also see if there is any success in specifying an “appPackage” but not setting “appActivity”… Its a combination I dont see in what you have tried already and Appium may be able to lock onto the package and then detect whatever activity is actually running.

Another thing to try is to isolate out Appium and make sure you can just launch the app with Android tools. A command line call to ADB like the following should start the app and activity if it exists

adb shell am start -n com.example.app/com.example.app.MainActivity

Here is some further reading:

Good Luck!

You are about to start your test correctly, but need to correct start activity. 2 ways:

  1. connect you phone to android studio ddms and start you app manually. In ddms logs identify activity that started first. Use it.

  2. note that start activity parameter can be like “.Main*”. Thus you can try to use even like “.*” and appium should take any activity which will start first.