手机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 <bundleId>
wanghaifengdeiMac:~ $ ideviceinstaller -U com.qeebox.qeebox
Uninstalling 'com.qeebox.qeebox'
- RemovingApplication (50%)
- GeneratingApplicationMap (90%)
- Complete
4、查看设备应用列表
命令参数为:ideviceinstaller [-u <device-udid>] -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 <device-udid>]:例如:
wanghaifengdeiMac:~ $ idevicesyslog -u 1cc7ad4ed7c9b7ac5164651d28a316b7d7d71dc9
[connected]
Dec 26 18:01:36 wanghaifengde-iPhone SpringBoard[58] <Notice>: CoreLocation: CLPocketStateService 100666.977362: monitorTime,10.000000,bksMonitorTime,12.000000,bksDelay,0.000349,proxStatus,1
Dec 26 18:01:36 wanghaifengde-iPhone kernel[0] <Notice>: AppleMultitouchN1SPI: ***** Multitouch Status: value=0x00010000 ts=0x00002735 *****
Dec 26 18:01:36 wanghaifengde-iPhone backboardd[60] <Notice>: [HID] [MT] MTSimpleHIDManager::deviceDidBootload device bootloaded
Dec 26 18:01:36 wanghaifengde-iPhone backboardd[60] <Notice>: [HID] [MT] MTSimpleHIDManager::setPropertyInternal detection mode: 6->6
Dec 26 18:01:36 wanghaifengde-iPhone SpringBoard[58] <Notice>: CoreLocation: CMPocketStateManager: QueryTimerFire,100667.278372
Dec 26 18:01:36 wanghaifengde-iPhone SpringBoard[58] <Notice>: CoreLocation: CMPocketStateManager 100667.278893: query response external=0 (OutOfPocket), internal=0, cbcount=2
Dec 26 18:01:36 wanghaifengde-iPhone SpringBoard[58] <Warning>: [MPUSystemMediaControls] Enabling lock screen media controls updates for screen turning on.
Dec 26 18:01:36 wanghaifengde-iPhone sharingd[63] <Notice>: 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
==> Downloading https://homebrew.bintray.com/bottles/apktool-2.0.2.yosemite.bott
curl: (6) Could not resolve host: d29vzk4ow07wi7.cloudfront.net
Error: Failed to download resource "apktool"
Download failed: https://homebrew.bintray.com/bottles/apktool-2.0.2.yosemite.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Downloading https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.0.
==> Downloading from https://bbuseruploads.s3.amazonaws.com/0becf6a1-1706-4f2e-9
######################################################################## 100.0%
? /usr/local/Cellar/apktool/2.0.2: 3 files, 6.0M, built in 6 minutes 33 seconds
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 <packageName>
如: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 <device-name>] 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 yueni-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.yueniapp.sns platformBuildVersionCode=23 platformBuildVersionName=6.0-2438415
9、安装包是否已经签名
wanghaifengdeiMac:Desktop chinaskin$ jarsigner -verify -verbose -certs yueniapp-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、安卓命令进行签名
工具:keytool,jarsigner
第一步:生成keystore
root@bt:~# keytool -genkey -alias dani.keystore -keyalg RSA -validity 4000 -keystore dani.keystore
第二步:签名
oot@bt:~/bubble example/dis/FrozenBubbleSignapk/META-INF# jarsigner -keystore dani.keystore -digestalg SHA1 -sigalg MD5withRSA -signedjar signed.apk unsigend.apk dani.keystore
第三步:优化
root@bt:~/bubble example# zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk
11、把一个已经存在的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
12、打印出apk包里的versionName
其中这些信息是保存在安卓工程项目里的
wanghaifengdeiMac:Desktop $ aapt d badging yueni-YN_TEST-release.apk|grep -o -E "versionName\='(.*)'\s"|grep -o -E "[0-9][^']*"
2.4.6a
正文到此结束