3

I wish to know how to set the app path for an android app on my mac. For iOS you can download the app and then in the desired capabilities you can provide the path.

I can't download the android version of the app onto my mac, but it is my understanding that I can use the android emulator and then install the app on it.

So how do I set the app path for this?

5 Answers 5

2

You can absolutely download an apk file to your mac. If you are getting the apk off of a build server, just download and then provide the path to the app within the appium gui. If you are using command line, provide the path in your desired capabilities.

Alternatively, you can install android studio and get access to source code. Then build from source and provide the build path to the GUI or capabilities.

2
  1. You should have .apk file with you and provide path in file path for mac(/filename.apk) on windows(\\filename.apk)

example:

String apkpath="/Users/fidel/Downloads/Test.apk";
File app=new File(apkpath);

then set the below capability

capabilities.setCapability("app", app.getAbsolutePath());
  1. Connect device and pair your system
  2. Run Appium (you can see log on Appium)
2
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "app/build/outputs/apk/");
File app = new File(appDir, "app-debug.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","Android");
capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "Your package name");
capabilities.setCapability("appActivity", "MainActivity");

Explanation:

Line 1: Get the Path to your Project's Root Directory O/P: classPathRoot: /Users/john.doe/AppiumProject/app

Line 2: Append the Path to the Directory of the folder where your ".apk" is placed, with the Project's Root Directory. O/P: classPathRoot: /Users/john.doe/AppiumProject/app/build/outputs/apk/

Line 3: Append your ".apk" file name, with the Project's Root Directory(till your apk folder). O/P: classPathRoot: /Users/john.doe/AppiumProject/app/build/outputs/apk/apk-debug.apk

Line 4 and onwards: Initiate Desired capabilitieas and set them as per your platform and device

2
  • 2
    Could you give some more context to your answer, please? Just posting code without any further information doesn't help much.
    – Kate Paulk
    Mar 11, 2015 at 10:59
  • @KatePaulk if needed
    – Ashish
    Sep 3, 2018 at 6:32
1

appPackage and appActivity capabilities should be used for installed Android apps.

They both can be found in the output of adb logcat command.

  1. Connect a device or launch an emulator;
  2. Execute your app;
  3. Execute adb logcat command;
  4. Search the output for Activity.
0

You can also provide URL into "app" capability. It even supports basic access authentication.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.