'Appium unknow error: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall

I launch Appium with administrator rights I use Allow session override from Advanced settings of appium

All i want is to launch an app from my device, which is already installed but i get this error: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall

And this is the code i try to run

package appiumtests;

import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;

public class Appiumtest {



    static AppiumDriver<MobileElement> driver;


    public static void main(String[] args) {

        try {
             openCasino();
        }catch(Exception exp) {
            System.out.println(exp.getCause());
            System.out.println(exp.getMessage());
            exp.printStackTrace();
        }       

    }

    public static void openCasino() throws Exception  {

        DesiredCapabilities cap = new DesiredCapabilities();


        cap.setCapability("deviceName","Mi A1");        
        cap.setCapability("udid","1d36c8469805");
        cap.setCapability("platformName", "Android");
        cap.setCapability("platformVersion", "9");
        cap.setCapability("appPackage", "eu.fortunagroup.casino.efortuna.ro.splashscreen.SplashScreenActivity");
        cap.setCapability("appActivity", "splashscreen.SplashScreenActivity.Casino");
        cap.setCapability("appWaitDuration,30000",true);
        cap.setCapability("", "");
        cap.setCapability("launchActivity ", "old.SplashActivity");
        cap.setCapability("newCommandTimeout", "3000");


        URL url = new URL("http://0.0.0.0:4723/wd/hub");    

        driver = new AppiumDriver<MobileElement>(url, cap);     

        System.out.println("Application Started");



    }   

}


Solution 1:[1]

For those who wanted to check if you are using the correct appPackage and appActivity, launch this via terminal or cmd.

If this adb command launches your APK file on your real device or emulator then that means [appPackage & appActivity] is valid. Play with Activity names or Packages until you hit the right values.

adb shell am start -W -n package_name/expected_activity_name -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000

Solution 2:[2]

I recommend you to install the app in the device and see if it is working by testing out appPackage and appActivity parameters alone.

You can find out if your appPackage and appActivity is correct by doing following

  1. Plug in your Android device and launch the application
  2. adb devices
  3. If there are device connected. Shell it
    adb shell
  4. Run this
    dumpsys window windows | grep -E ‘mCurrentFocus’

Refer to image . You will get appPackage and appActivity.

Let me know if this is working for the 2 parameters.

enter image description here

Still cannot work ? Test if your appActivity or appPackage is correct
If the above does not work , do this with the app installed

adb shell am start -n com.package.name/com.package.name.ActivityName



If this still does not work , you have most likely got either the appName or appActivity incorrect.


Reference : https://medium.com/@ivantay2003/appium-desired-capabilities-basic-cheat-sheet-to-launch-mobile-application-ios-android-75b664367031

Solution 3:[3]

I fixed the issue!

All i had to do was to add JDK to Eclipse. It can be found here: Setting JDK in Eclipse

Right click your project > properties Select “Java Build Path” on left, then “JRE System Library”, click Edit… Select "Workspace Default JRE" Click "Installed JREs" If you see JRE you want in the list select it (selecting a JDK is OK too) If not, click Search…, navigate to Computer > Windows C: > Program Files > Java, then click OK Now you should see all installed JREs, select the one you want Click OK/Finish a million times

Instead of JRE i selected JDK folder and the app launched.

Thank you all!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 batuzai04123
Solution 2
Solution 3 Constantin Vasile