一、手机或模拟器上已安装app(美团为例)
方法一:在命令行输入adb shell am monitor,按Enter,再启动想要获取的app
(包名在最后一行:com.sankuai.meituan)
C:\Users\starteos>adb shell am monitor
Monitoring activity manager... available commands:
(q)uit: finish monitoring
** Activity starting: com.sankuai.meituan
方法二:先启动想要获取的app,再输入命令:adb shell dumpsys window w | findstr / | findstr name=,按Enter
(包名在倒数第二行)
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
方法三:先启动想要获取的app,再输入命令:adb shell dumpsys window | findstr mCurrentFocus,按Enter
(包名在中间)
C:\Users\starteos>adb shell dumpsys window | findstr mCurrentFocus
mCurrentFocus=Window{11b2959 u0 com.sankuai.meituan/com.meituan.mmp.lib.mp.MPActivity0}
方法四:获取手机第三方所有应用的包名,输入命令:adb shell pm list package -3,按Enter
(包名在最后一行,每台设备具体位置不同)
C:\Users\starteos>adb shell pm list package -3
package:io.appium.settings
package:com.smarttoolfactory.tutorial3_1transitions
package:com.sankuai.meituan
二、电脑上有apk安装包
输入命令:aapt dump badging + apk路径
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'
输入命令:aapt dump xmltree + apk路径 + 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")
————————————————
版权声明:本文为CSDN博主「文字有奇效」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/kldzh/article/details/127567585