测试开发

移动应用平台相关操作命令

LensNews

可以说,随着2010年智能手机的问世,我们的生活就开始进入到了移动互联网时代。

伴随着我们身边就是层出不穷的移动app   为此,我们应该多了解一些关于移动应用方面的知识

对于我们的生活以及工作确实方便了许多。其中一些数据来源于网络,并重新进行分类整理并更新。

一、iOS相关操作命令

1、安装iOS命令
iOS 用到的ideviceinstaller,安装命令为:brew install libimobiledevice
2、安装应用
安装应用的命令为:ideviceinstaller  -i  xxx.ipa
也可以通过fruitstrap命令来安装,以下为命令
wanghaifengdeiMac:fruitstrap $ ./fruitstrap
usage: ./fruitstrap [-d/--debug] [-i/--id device_id] -b/--bundle bundle.app [-a/--args arguments] [-t/--timeout timeout(seconds)] [-u/--unbuffered]
3、卸载应用
卸载应用的命令为:ideviceinstaller -U
wanghaifengdeiMac:~ $ ideviceinstaller -U com.qeebox.qeebox
Uninstalling 'com.qeebox.qeebox'
- RemovingApplication (50%)
- GeneratingApplicationMap (90%)
- Complete
4、查看设备应用列表
命令参数为:ideviceinstaller [-u] -l,当只有一个设备连接时,就可以省掉udid
wanghaifengdeiMac:~ $ ideviceinstaller -l
Total: 64 apps
com.tencent.info - 腾讯新闻 4.8.5.79576
com.51zhangdan.xinyongka - 51信用卡管家 24
com.alipay.iphoneclient - 支付宝 9.3.1.113028
com.meituan.imeituan - 美团 852
com.baidu.BaiduMobile - 手机百度 7.0.0.0
com.chinaunicom.mobilebusiness - 手机营业厅 157
com.tencent.xin - 微信 6.3.8.17
com.gw.dzhiphone622 - 大智慧 8.22
com.aliyun.wstudio.amc.AliyunMobileApp - 阿里云 1590
com.sogou.sogouinput - 搜狗输入法 84078
com.ucweb.iphone.lowversion - UC浏览器 10.7.11.672
5、显示所有的设备列表
会显示所有的真机、mac、模拟器的udid命令:instruments -s devices
wanghaifengdeiMac:~ $ instruments -s devices
Known Devices:
2015-12-26 18:12:30.166 instruments[4761:181199] WebKit Threading Violation - initial use of WebKit from a secondary thread.
王海峰的iMac [DA5E585E-F33C-5665-BB3C-A094796B6E73]
王海峰的 iPhone (9.2) [1cc7ad4ed7c9b7ac5164651d28a316b7d7d71dc9]
Apple TV 1080p (9.1) [07F01A21-6DD2-47E5-8104-D9E569660217]
iPad 2 (9.2) [9E32F7DD-6124-411D-818E-F88838AF6C71]
iPad Air (9.2) [C6858C2F-B7BC-4F2E-BFEC-71194B6315E3]
iPad Air 2 (9.2) [CE7930D1-6F27-4BCD-A095-8BC9264D5B65]
iPad Pro (9.2) [2885B8D4-C6FC-4169-A867-5ADA33DB8D7C]
6、获取设备的运行日志
命令参数:idevicesyslog [-u]:例如:
wanghaifengdeiMac:~ $ idevicesyslog -u 1cc7ad4ed7c9b7ac5164651d28a316b7d7d71dc9
[connected]
Dec 26 18:01:36 wanghaifengde-iPhone SpringBoard[58]: CoreLocation: CLPocketStateService 100666.977362: monitorTime,10.000000,bksMonitorTime,12.000000,bksDelay,0.000349,proxStatus,1
Dec 26 18:01:36 wanghaifengde-iPhone kernel[0]: AppleMultitouchN1SPI: ***** Multitouch Status: value=0x00010000 ts=0x00002735 *****
Dec 26 18:01:36 wanghaifengde-iPhone backboardd[60]: [HID] [MT] MTSimpleHIDManager::deviceDidBootload device bootloaded
Dec 26 18:01:36 wanghaifengde-iPhone backboardd[60]: [HID] [MT] MTSimpleHIDManager::setPropertyInternal detection mode: 6->6
Dec 26 18:01:36 wanghaifengde-iPhone SpringBoard[58]: CoreLocation: CMPocketStateManager: QueryTimerFire,100667.278372
Dec 26 18:01:36 wanghaifengde-iPhone SpringBoard[58]: CoreLocation: CMPocketStateManager 100667.278893: query response external=0 (OutOfPocket), internal=0, cbcount=2
Dec 26 18:01:36 wanghaifengde-iPhone SpringBoard[58]: [MPUSystemMediaControls] Enabling lock screen media controls updates for screen turning on.
Dec 26 18:01:36 wanghaifengde-iPhone sharingd[63]: 18:01:36.585 : BTLE scanning started
7、查看设备的udid
命令安装:brew install usbmuxd;brew install ideviceinstaller
wanghaifengdeiMac:~ $ idevice_id -l
1cc7ad4ed7c9b7ac5164651d28a316b7d7d71dc9
8、iOS项目编译
下面可以为shell脚步实例
echo "wisetop" | security unlock-keychain  ~/Library/Keychains/login.keychain
xcodebuild -archivePath "/Users/wanghaifeng/buildiOS/testProject.xcarchive" -workspace testProject.xcworkspace -sdk iphoneos -scheme "testProject" -configuration "Debug" archive
xcodebuild -exportArchive -exportFormat IPA -archivePath "/Users/wanghaifeng/buildiOS/testProject.xcarchive" -exportPath "/Users/wanghaieng/buildiOS/testProject.ipa"
cd /Users/wanghaifeng/Tools/fruitstrap
./fruitstrap -b "/Users/wanghaifeng/buildiOS/testProject.ipa"

二、Android相关操作明

1、命令安装
Android用到的命令是:apktool,首先要安装apktool
wanghaifengdeiMac:Desktop wanghaifeng$ brew install apktool
curl: (6) Could not resolve host: d29vzk4ow07wi7.cloudfront.net
Error: Failed to download resource "apktool"
Warning: Bottle installation failed: building from source.
######################################################################## 100.0%
2、安装应用
安装应用的命令为:adb install xxxxxx.apk
3、查看设备中的应用列表
需要输入的命令:adb shell pm list packages
wanghaifengdeiMac:Desktop $ adb shell pm list packages
package:com.vivo.securedaemonservice
package:com.vivo.simplemusic
package:com.qualcomm.qti.modemtestmode
package:com.vivo.minscreen
package:com.github.lzyzsd.jsbridge.example
package:com.vivo.setupwizard
package:com.qualcomm.cabl
package:com.android.bbkcalculator
...
4、卸载应用
adb uninstall
如:adb uninstall com.vivo.setupwizard
其中:com.vivo.setupwizard为包名
5、源码编译
设置了gradle的环境变量,因为直接编译即可gradle build,也可以通过gradle clean assembleRelease --stacktrace
wanghaifengdeiMac:androidSns $ gradle build
:ImageViewTouch:compileLint
:ImageViewTouch:copyDebugLint UP-TO-DATE
:ImageViewTouch:preBuild UP-TO-DATE
:ImageViewTouch:preDebugBuild UP-TO-DATE
:ImageViewTouch:checkDebugManifest
:ImageViewTouch:preDebugAndroidTestBuild UP-TO-DATE
:ImageViewTouch:preDebugUnitTestBuild UP-TO-DATE
:ImageViewTouch:preReleaseBuild UP-TO-DATE
….
6、显示所收的设备
查看所有的安卓设备:adb devices
wanghaifengdeiMac:~ $ adb devices
List of devices attached
d70cf294 device
7、获取真机实时日志
命令参数:adb [-s] logcat , 例如: adb -s d70cf294 logcat
wanghaifengdeiMac:~ $ adb -s d70cf294 logcat
--------- beginning of system
V/WindowManager( 2228): Fullscreen window: Window{39bdcbc2 u0 com.bbk.launcher2/com.bbk.launcher2.Launcher}
D/ScreenBrightnessModeRestore( 2228): onForegroundActivitiesChanged pid=22076 mCurrentForceGroundPid=4475
V/WindowManager( 2228): ** SHOWING status bar: top is not fullscreen
V/WindowState( 2228): showLw, win = Window{27c62b64 u0 StatusBar}, isHiddenFromUserLocked() = false, mAppOpVisibility = true, Callers = com.android.server.wm.WindowState.showLw:1151 com.android.internal.policy.impl.BarController.setBarShowingLw:138 com.android.internal.policy.impl.PhoneWindowManager.finishPostLayoutPolicyLw:4679
I/WindowManager( 2228): setOccluded(false)
W/ActivityManager( 2228): getRunningAppProcesses: caller 10050 does not hold REAL_GET_TASKS; limiting output
V/WindowManager( 2228): Fullscreen window: Window{39bdcbc2 u0 com.bbk.launcher2/com.bbk.launcher2.Launcher}
V/WindowManager( 2228): ** SHOWING status bar: top is not fullscreen
V/WindowState( 2228): showLw, win = Window{27c62b64 u0 StatusBar}, isHiddenFromUserLocked() = false, mAppOpVisibility = true, Callers = com.android.server.wm.WindowState.showLw:1151 com.android.internal.policy.impl.BarController.setBarShowingLw:138 com.android.internal.policy.impl.PhoneWindowManager.finishPostLayoutPolicyLw:4679
8、获取应用唯一标识
首先是解压apk到test目录下,然后针对AndroidManifest.xml文件的数据进行获取
wanghaifengdeiMac:Desktop $ apktool d yueniapp-YN_TEST-release.apk -o test
I: Using Apktool 2.0.2 on yueniapp-YN_TEST-release.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /Users/chinaskin/Library/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
wanghaifengdeiMac:Desktop $ cd test
wanghaifengdeiMac:test $ cat AndroidManifest.xml | grep -o "package=\".*\"" | sed "s/package=\"//g" | sed "s/\"//g"
com.yueni.sns platformBuildVersionCode=23 platformBuildVersionName=6.0-2438415
9、安装包是否已经签名
wanghaifengdeiMac:Desktop $ jarsigner -verify -verbose -certs yueni-YN_TEST-release.apk
sm     29488 Fri Feb 29 10:33:46 CST 2008 AndroidManifest.xml
X.509, EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[证书的有效期为08-2-29 上午9:33至35-7-17 上午9:33]
[CertPath 未验证: Path does not chain with any of the trust anchors]
X.509, EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[证书的有效期为08-2-29 上午9:33至35-7-17 上午9:33]
[证书的有效期为08-2-29 上午9:33至35-7-17 上午9:33]
[CertPath 未验证: Path does not chain with any of the trust anchors]
s = 已验证签名
m = 在清单中列出条目
k = 在密钥库中至少找到了一个证书
i = 在身份作用域内至少找到了一个证书
jar 已验证。
警告:
此 jar 包含证书链未验证的条目。
此 jar 包含的签名没有时间戳。如果没有时间戳, 则在签名者证书的到期日期 (2035-07-17) 或以后的任何撤销日期之后, 用户可能无法验证此 jar。
10、把一个已经存在的APK的相关包与资源路径显示出来,通过aapt命令
aapt l -a  test.apk > test.txt
如:
wanghaifengdeiMac:Desktop wanghaifeng$ aapt l -a yueni-YN_TEST-release.apk > test.txt
wanghaifengdeiMac:Desktop wanghaifeng$ ls
test.txt     yueni-YN_TEST-release.apk
wanghaifengdeiMac:Desktop chinaskin$ cat test.txt
AndroidManifest.xml
assets/public.v1.zip
assets/setting.txt
res/anim/abc_fade_in.xml
res/anim/abc_fade_out.xml
res/anim/abc_grow_fade_in_from_bottom.xml
res/anim/abc_popup_enter.xml
res/anim/abc_popup_exit.xml
res/anim/abc_shrink_fade_out_from_bottom.xml
res/anim/abc_slide_in_bottom.xml
res/anim/abc_slide_in_top.xml
res/anim/abc_slide_out_bottom.xml
res/anim/abc_slide_out_top.xml
res/anim/black_anim.xml
res/anim/camera_end.xml
11、打印出apk包里的versionName
其中这些信息是保存在安卓工程项目里的
wanghaifengdeiMac:Desktop $ aapt d badging yueni_TEST-release.apk|grep -o -E "versionName\='(.*)'\s"|grep -o -E "[0-9][^']*"
(1)

本文由 小蜜蜂信息网 作者:admin 发表,转载请注明来源!

关键词:,
LensNews

热评文章

评论:

1 条评论,访客:1 条,博主:0 条
  1. 云飞扬
    云飞扬发布于: 

    写的很全面,幸苦了

发表评论