How to run .apk on Saucelabs using Android emulator?

1k views Asked by At

I want to run facebook.apk at saucelabs. I successfully downloaded apk file to sauce server using curl acording to SauceLabs instructions.

I used this code to launch application:

capabilities.setCapability("appiumVersion", "1.4.0");
capabilities.setCapability("automationName", "Selendroid");
capabilities.setCapability("deviceName","Android Emulator");
capabilities.setCapability("platformVersion","4.2");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app","sauce-storage:facebook.apk");
capabilities.setCapability("appActivity","com.facebook.katana.FacebookLoginActivity");  
capabilities.setCapability("appPackage", "com.facebook.katana");
capabilities.setCapability("newCommandTimeout", "300000");
try {
    BaseAppiumTest.driver = new RemoteWebDriver
            (new URL("http://SL_name_private:[email protected]:80/wd/hub"), capabilities);
} catch (MalformedURLException e) {
    e.printStackTrace();
}

And I constantly used to get this error:

POST /session 0 (+0.28s) desiredCapabilities: {"deviceName":"Android Emulator","automationName":"Selendroid","proxy":{"proxyAutoconfigUrl":"http://127.0.0.1:19876/pac.js","proxyType":"PAC"},"newCommandTimeout":"300000","platformVersion":"4.2","platformName":"Android"} => A new session could not be created. (Original error: hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: dump failed because no AndroidManifest.xml found )

I have checked fb.apk locally and, seems, it was downloaded correctly, as well.

1

There are 1 answers

0
Sooraj On

You don't need to provide (automationName, appActivity, appPackage) capabilities while executing tests in Saucelabs emulators.

You can use the sample capabilities below:

caps.setCapability("appiumVersion", "1.13.0");
caps.setCapability("deviceName", "Samsung Galaxy S9 WQHD GoogleAPI 
      Emulator");
caps.setCapability("deviceOrientation", "portrait");
caps.setCapability("browserName", "");
caps.setCapability("platformVersion", "9.0");
caps.setCapability("platformName", "Android");
caps.setCapability("app", "sauce-storage:WhatsApp.apk");