This part of the handbook is a WIP.
ADB Tips and Tricks
Setup
- Download latest Android studio from https://developer.android.com/studio/ .
- Install and finish the setup.
- Start terminal and use:
- defaults write com.apple.Finder AppleShowAllFiles true
- Kill all Finder
- You can use “nano .bash_profile” or “.zshrc” to open GNU nano console
- Then we insert alias we want to have. To use aliases we specify name of the alias and then we specify path to the file it will use. In my case:
- export PATH=$PATH:/Users/poviolabs/Library/Android/sdk/platform-tools
- export PATH=$PATH:/Users/poviolabs/Library/Android/sdk/tools
- export PATH=$PATH:/Users/poviolabs/Library/Android/sdk/build-tools/28.0.X
- export ANDROID_HOME=/Users/poviolabs/Library/Android/
- When you finish specifying aliases use CTRL+X combination to exit nano GNU, but he will ask you to save the changes and you press Y and then Enter.
- The final step is to use “source .bash_profile” or .zshrc command in the terminal
Commands
Android version —> adb shell getprop ro.build.version.release Tells you android version of connected device
Phone model —> adb shell getprop ro.product.model Tells you model of connected device
App install —-> adb install insert here insert here-Path to the .apk file
App install on SD card —-> adb install -s insert here insert here-Path to the .apk file
App reinstall (app upgrade) —-> adb install -r insert here insert here-Path to the .apk file
App install using OBB file(Now only possible with rcc build) —-> adb install dev_relaxroll_build24.apk adb push main.17.com.relaxroll.b9.obb /mnt/sdcard/Android/obb/com.outfit7.mytalkingtomfree/main.17.com.relaxroll.obb
App uninstall —-> adb uninstall insert here insert here-App package name like: com.outfit7.mytalkingtomfree
ANR pull —-> adb pull /data/anr ~/Documents ANR will be saved to Documents folder
ANR read(Samsung tab) —-> adb shell When in shell cd /data/anr && cat traces.txt ANR will be printed out in console Logs —-> adb logcat -v time -d > ~/Downloads/android-log.txt Logcat will be saved in /Downloads/android-log.txt
To uninstall an app (for all users) use ( example): adb uninstall com.relaxroll (appname)
Alternative for logs —–> adb logcat -b main -b system -b events 2>&1 | tee ~/Desktop/log.txt |
Screenshot from connected device
alias screenShot=' DATE=$(date +"%Y-%m-%d_%H-%M-%S") &&
adb shell screencap -p /sdcard/screencap.png &&
sleep 1 &&
adb pull /sdcard/screencap.png ~/Documents/Screenshots/screenshot_$DATE.png &&
open ~/Documents/Screenshots/screenshot_$DATE.png &&
echo "Done, created file: screenshot_"$DATE" It is in directory Documents in folder screenshots. Use it wisely!!"'
Print out specific log form —–> adb logcat | grep -E “#AdPlugin” |
Version code on Alpha build —> adb shell dumpsys package com.relaxroll | grep version |
Setting up a server: alias server=’ifconfig en0 | grep -o “inet [0-9.]*” | cut -d “ “ -f2 ; python -m SimpleHTTPServer’
- Stress test on device or hunt for uncaught exceptions (can be useful in very specific situations )
- adb shell monkey -p your.package.name –throttle 200 -v 505 Command above will send 505 events to connected device with 200 ms delay (more info on http://developer.android.com/tools/help/monkey.html)
iOS logs in terminal
If you want to grep for iOS logs in terminal you should do the following:
Go to terminal Write the following command (this will install homebrew package manager for macOS):
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
Wait for it to finish installing Enter the following command (installs a needed package): Also click on “Trust” when the device is asking for trusting the computer you are connected to
brew install libimobiledevice
You are all set, now you just need to enter the grep command, example:
sudo idevicesyslog | grep -i ‘AddBqEvent {“gid”:’ |
If you are still having issues (getting an error: Could not start service com.apple.syslog_relay) try doing: brew uninstall libimobiledevice brew install –HEAD libimobiledevice