The method of adb to obtain the app package name

1. The app has been installed on the mobile phone or emulator (Meituan as an example)

  1. Method 1: Enter adb shell am monitor on the command line, press Enter, and then start the app you want to get
    (the package name is on the last line: com.sankuai.meituan )
C:\Users\starteos>adb shell am monitor
Monitoring activity manager...  available commands:
(q)uit: finish monitoring
** Activity starting: com.sankuai.meituan
  1. Method 2: Start the app you want to get first, and then enter the command: adb shell dumpsys window w | findstr / | findstr name=, press Enter
    (the package name is on the penultimate line)
C:\Users\starteos>adb shell dumpsys window w | findstr \/ | findstr name=
      mSurface=Surface(name=GestureNavBottom)/@0x13b0c39
      mSurface=Surface(name=GestureNavRight)/@0x1108b23
      mSurface=Surface(name=GestureNavLeft)/@0x1108b89
       mAnimationIsEntrance=true      mSurface=Surface(name=StatusBar)/@0xcaf1d1
      mSurface=Surface(name=PopupWindow:b18885b)/@0x11b9aa5
      mSurface=Surface(name=com.sankuai.meituan/com.meituan.mmp.lib.mp.MPActivity0)/@0x1170be9
       mAnimationIsEntrance=true      mSurface=Surface(name=com.android.systemui.HwImageWallpaper)/@0x10b4741
  1. Method 3: Start the app you want to get first, and then enter the command: adb shell dumpsys window | findstr mCurrentFocus, press Enter
    (the package name is in the middle)
C:\Users\starteos>adb shell dumpsys window | findstr mCurrentFocus
  mCurrentFocus=Window{
    
    11b2959 u0 com.sankuai.meituan/com.meituan.mmp.lib.mp.MPActivity0}
  1. Method 4: Obtain the package names of all third-party applications on the mobile phone, enter the command: adb shell pm list package -3, and press Enter
    (the package name is on the last line, and the specific location is different for each device)
C:\Users\starteos>adb shell pm list package -3
package:io.appium.settings
package:com.smarttoolfactory.tutorial3_1transitions
package:com.sankuai.meituan

2. There is an apk installation package on the computer

  1. Enter the command: aapt dump badging + apk path
C:\Users\starteos>aapt dump badging D:\meituan_ui\app\imeituan.apk
package: name='com.sankuai.meituan' versionCode='1200020206' versionName='12.2.206' platformBuildVersionName='12.2.206' compileSdkVersion='29' compileSdkVersionCodename='10'
  1. Enter the command: aapt dump xmltree + apk path + AndroidManifest.xml | findstr "package"
C:\Users\starteos>aapt dump xmltree D:\meituan_ui\app\imeituan.apk AndroidManifest.xml | findstr "package"
    A: package="com.sankuai.meituan" (Raw: "com.sankuai.meituan")

Guess you like

Origin blog.csdn.net/kldzh/article/details/127567585