0

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");



    }   

}
  • Domnu Vasile, the error happens on server-side, so I would advise you to check the server logs to find what the issue is. – Lajos Arpad Oct 17 '19 at 12:05
  • What is `launchActivity` capability? and btw you added a space after it, this won't work. Try to remove that capability and run it one more time. – Vault23 Oct 17 '19 at 12:10
  • @LajosArpad - server logs are here: https://pastebin.com/EGzTcQcN – Constantin Vasile Oct 17 '19 at 12:16
  • @Vault23 i removed that cap and redo. Same error. On the above comment are the server logs. thank you – Constantin Vasile Oct 17 '19 at 12:18
  • `'eu.fortunagroup.casino.efortuna.ro.splashscreen.SplashScreenActivity' is not installed` check your `appPackage` and `appActivity` again please – Vault23 Oct 17 '19 at 12:19
  • Multumesc, Constantin, however, this seems to be the logs of your phone app, rather than the server. The error message "An unknown server-side error occurred while processing the command." says that something undetermined and bad happened on the server. Luckily, it adds that the original error is 'app' option is required for reinstall, which, if true means that you need to specify an 'app' option. – Lajos Arpad Oct 17 '19 at 12:57
  • @LajosArpad its not. As you can see there are logs of [appium] (that means `server` logs), [adb] and [baseDriver]. Furthermore, there are no `logcat` logs, which means "phone logs". And, like i said before, the original error is the wrong value of `appPackage` – Vault23 Oct 17 '19 at 13:05
  • Thanks a lot, guys. I need to figure out which is the correct appPackage and appActivity. <3 – Constantin Vasile Oct 17 '19 at 13:09

5 Answers5

0

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

batuzai04123
  • 379
  • 5
  • 12
  • Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=eu.fortunagroup.casino.efortuna.ro/com.playtech.unified.splashscreen.SplashScreenActivity } Status: ok Activity: eu.fortunagroup.casino.efortuna.ro/com.playtech.unified.splashscreen.SplashScreenActivity ThisTime: 1423 TotalTime: 1423 WaitTime: 1463 Complete The app started, yet i cannot launch it using appium – Constantin Vasile Oct 18 '19 at 06:16
  • @ConstantinVasile Try updating your appium desktop to latest, I believe 1.15.1 is already available. – batuzai04123 Oct 18 '19 at 13:31
0

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

john
  • 413
  • 7
  • 16
  • Hi. The app is already installed and perfectly working. I did what u suggested and found: cmp=eu.fortunagroup.casino.efortuna.ro/com.playtech.unified.splashscreen.SplashScreenActivity Using these, i still cannot launch the app – Constantin Vasile Oct 18 '19 at 06:06
  • There may be another possibility. Even though I get the appActivity as in the above method, but there could be an earlier activity which was not caught by this method. The appActivity appear earlier but when we shell , it was a later activity that is not correct. I found out this even when I was using this method. I found out from the dev there was a earlier activity before this (but it disappear very fast). One way is to confirm with the dev this is the first activity when launch. If app is already installed then set noReset to true. The error should disappear. – john Oct 18 '19 at 07:45
  • I have amended the answer and added the adb command. If the adb cmd does not work , it is likely appActivity or appPackage is wrong. – john Oct 18 '19 at 07:57
  • Hi @john - I fixed the issue. All i had to do is to add JDK to Eclipse. I commented above the answer. Thank you! – Constantin Vasile Oct 18 '19 at 08:02
0

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!

0

Try commands in terminal or cmd

adb uninstall io.appium.settings
adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server.test
adb uninstall io.appium.unlock
0

I forgot to manually launch the app first, before running the test with "driver.resetApp()".

Andre Thiele
  • 3,202
  • 3
  • 20
  • 43