折腾:
【未解决】uiautomator2中如何获取到欢乐大作战游戏界面中的元素
期间,要去搞清楚
“通过atx-agent解析apk包的mainActivity”
此处是安卓游戏app:欢乐大作战
atx-agent解析apk mainActivity
解析apk mainActivity
那貌似:aapt之类的也可以解析啊
去试试
➜ ~ which aapt aapt not found
此处没有aapt
此处之前有下载,所以先去试试是否可用
如果可用,再加到PATH中
还要下载游戏apk
-》
去解析:
➜ 28.0.3 pwd /Users/crifan/dev/dev_tool/android/AndroidSDK/build-tools/28.0.3 ➜ 28.0.3 ./aapt dump badging /Users/crifan/dev/dev_tool/android/apk/HappyBigBattle.apk package: name='com.hldzz.dmw' versionCode='20' versionName='444' compileSdkVersion='28' compileSdkVersionCodename='9' install-location:'auto' sdkVersion:'16' targetSdkVersion:'28' uses-permission: name='android.permission.INTERNET' uses-permission: name='android.permission.ACCESS_NETWORK_STATE' uses-permission: name='android.permission.ACCESS_WIFI_STATE' uses-permission: name='com.android.vending.BILLING' uses-permission: name='com.hldzz.dmw.permission.JPUSH_MESSAGE' uses-permission: name='android.permission.RECEIVE_USER_PRESENT' uses-permission: name='android.permission.READ_PHONE_STATE' uses-permission: name='android.permission.READ_EXTERNAL_STORAGE' uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE' uses-permission: name='android.permission.MOUNT_UNMOUNT_FILESYSTEMS' uses-permission: name='com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE' uses-permission: name='android.permission.VIBRATE' uses-permission: name='android.permission.ACCESS_FINE_LOCATION' uses-permission: name='android.permission.ACCESS_COARSE_LOCATION' application-label:'欢乐大作战' application-label-zh:'欢乐大作战' application-icon-120:'res/drawable-ldpi-v4/app_icon.png' application-icon-160:'res/drawable-mdpi-v4/app_icon.png' application-icon-240:'res/drawable-hdpi-v4/app_icon.png' application-icon-320:'res/drawable-xhdpi-v4/app_icon.png' application-icon-480:'res/drawable-xxhdpi-v4/app_icon.png' application-icon-640:'res/drawable-xxxhdpi-v4/app_icon.png' application: label='欢乐大作战' icon='res/drawable-mdpi-v4/app_icon.png' banner='res/drawable-xhdpi-v4/app_banner.png' application-isGame launchable-activity: name='com.hldzz.dmw.MainActivity' label='欢乐大作战' icon='' leanback-launchable-activity: name='com.hldzz.dmw.MainActivity' label='欢乐大作战' icon='' banner='' feature-group: label='' uses-gl-es: '0x20000' uses-feature-not-required: name='android.hardware.sensor.accelerometer' uses-feature-not-required: name='android.hardware.touchscreen' uses-feature-not-required: name='android.hardware.touchscreen.multitouch' uses-feature-not-required: name='android.hardware.touchscreen.multitouch.distinct' uses-feature: name='android.hardware.location' uses-implied-feature: name='android.hardware.location' reason='requested android.permission.ACCESS_COARSE_LOCATION permission, and requested android.permission.ACCESS_FINE_LOCATION permission' uses-feature: name='android.hardware.screen.landscape' uses-implied-feature: name='android.hardware.screen.landscape' reason='one or more activities have specified a landscape orientation' uses-feature: name='android.hardware.wifi' uses-implied-feature: name='android.hardware.wifi' reason='requested android.permission.ACCESS_WIFI_STATE permission' main other-activities other-receivers other-services supports-screens: 'small' 'normal' 'large' 'xlarge' supports-any-density: 'true' locales: '--_--' 'zh' densities: '120' '160' '240' '320' '480' '640' native-code: 'armeabi-v7a'
此app的mainActivity应该就是
com.hldzz.dmw.MainActivity
顺带看到了其他相关信息:
- 包名=package name
- com.hldzz.dmw
- 启动主界面=launchable activity
- com.hldzz.dmw.MainActivity
- app名字=label
- 欢乐大作战
【总结】
用aapt去解析apk可以得到想要的MainActivity和其他相关信息。
此处app:HappyBigBattle.apk
解析:
aapt dump badging HappyBigBattle.apk
得到:
- 包名=package name
- com.hldzz.dmw
- 启动主界面=launchable activity
- com.hldzz.dmw.MainActivity
- app名字=label
- 欢乐大作战