SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

How To Find .Apk File Package Name And Launcher Activity Name

In previous step, we learnt about how to locate android native software app elements by XPath, ID and className and We will learn how to run your first android software app test in next step. But before creating your first android native software app, You must know how to find package name and launcher activity name of your android app which you are going to test using appium. Because we need to provide package name and launcher activity name of android software app in test script to launch it in device or emulator. This post will describe you how to get package name and launcher activity name of.APK file using different ways. More 2 methods of finding package name and launcher activity name are given on THIS PAGE.

PREREQUISITES : Previous appium tutorial's 10 STEPS should be completed.

Method 1 : Using APK Info App
If your android app is installed in device and you need it's package name and launcher activity name then you can use APK Info android app to get detailed information of any installed application. Let's try to get package name and launcher activity name of app called Contact Manager which i have installed. You can follow same steps for any app.
  • Go to GOOGLE PLAY STORE, Search for app using keyword "APK Info".
  • It will show you list of apps. There will be app with name APK info as shown in bellow image.
  • Install this android software app in your android device.
  • Alternatively you can download APKInfo app from THIS PAGE too. 
  • Launch APK info app in android device. 
  • It will show you list of all installed apps in your device. Locate Contact Manager android software app from list which is supplied by APK info app. Tap on Contact Manager app for 2 to 3 seconds.
  • It will show you popup message as shown in bellow image. Select Detailed Information option.
  • It will show you your Contact Manager app detail as shown in bellow image.
  • See above image, APK path contains App Package name. So Package name for Contact Manager app is com.example.android.contactmanager and Activity Name for Contact Manager app is com.example.android.contactmanager.ContactManager.
Method 2 : Using Command Prompt
This is another way to get android app package and activity name. Let's try to get package name for Contact Manager app.

Get Package Name
  • Connect your android phone with PC and turn on USB debugging mode as described in THIS POST.
  • Open Command prompt.
  • Run command adb shell pm list packages -f
  • It will show you list of apps(Which are installed in your device) with package name.
  • Find your app from list. It will show you package name as shown in bellow image.
  • Bellow given image shows package name of Contact Manager app.
  • Package name for Contact Manager app is com.example.android.contactmanager.
Method 3 : Using logcat In Command Prompt
  • Connect your android phone with PC and turn on USB debugging mode.
  • Open Command prompt.
  • Run command adb logcat.
  • Open app in android phone. Immediately press CTRL + C in command prompt to stop logging in command prompt.
  • Android phone's latest activity will be logged in command prompt.
  • If you see in log, It will show you app launcher log as shown bellow.
  • Here com.example.android.contactmanager is package name and com.example.android.contactmanager.ContactManager is activity name of Contact Manager app.
This way you can get any android software application's package name and launcher activity name easily. We have to use both these parameters in test script.

10 comments:


  1. org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c "D:\android-sdk-windows\android-sdk-windows\platform-tools\adb.exe -s 330016442947a235 push "C:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/"
    protocol failure
    ) (WARNING: The server did not provide any stacktrace information)
    getting this error. please help me

    ReplyDelete
    Replies
    1. try again.. It will work on 2nd or 3rd try if everything is installed and working fine.

      Delete
  2. i could not find contact manager in apk info

    ReplyDelete
    Replies
    1. I was confused about this also (I think I know what you're saying). Contact Manager is the app the tutorial installed, not a general place to look for your apk path or activity (if you haven't installed it yourself, then it won't be there). Search for the app whose apk and activity path you wish to learn and do what this page does to Contact Manager (click for 2+ seconds... etc.)

      Delete
    2. I was confused about this also, but realized Contact Manager is not the general place to look for your apk path etc. Its an app the tutorial must have installed. Instead search for the app you wish to find the apk path for and follow the instructions from there.

      Delete
  3. Hi ,

    Nice tutorials but i am using Appium to get package name and activity name in appium where it is showing empty after showing apk file,Please help how to get package name and activity name and one more ,when i open my testing app showing 6 activities names which one i need to select all are showing as ui.auto etc..../activities.please help

    ReplyDelete
  4. Hi,
    Thanks for tutorials, we are planning to use appium for mobile testing in our project and have follwed ur tutorials and installed till this post "http://www.software-testing-tutorials-automation.com/2015/10/how-to-find-apk-file-package-name-and.html", but i could not find contact manager in my apk info and my phone is Moto-X.
    Please help me with this.

    Thanks in advance,
    Madhu

    ReplyDelete
  5. Hi,

    Try below steps.

    -Launch your app.
    -Go to command prompt and type : adb shell
    -This will enter to device root.
    -Then type dumpsys window windows | grep -E 'mcurrentFocus|mFocusedApp'
    -My output for chrome is
    mFocusedApp=AppWindowToken{531c1b30 token=Token{52ba7648 ActivityRecord{52b851
    04 u0 com.android.chrome/org.chromium.chrome.browser.ChromeTabbedActivity t29}}}

    -from output appPackage : com.android.chrome
    and appActivity : org.chromium.chrome.browser.ChromeTabbedActivity

    ReplyDelete