Wednesday 11 January 2017

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

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.

No comments:

Post a Comment