Android tips&tricks

adb cheat sheet

  • get crash reports: adb logcat -b crash
  • logcat of your app version debug: adb logcat --pid=$(adb shell pidof -s org.courville.nova) -v color
  • scan a file: adb shell "am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://FILE_PATH"
  • dump MediaStore files: adb shel content query --uri "content://media/external/file"
  • set serial number export ANDROID_SERIAL="8ANY0NJAH"
  • more...

git/repo cheat sheet

  • force push:¬†git push -f github HEAD:nova
  • get all repo diff: repo diff -u
  • partial add file: git add -p file
  • rebasing squash etc.:¬†git rebase -i hash-commit-before
  • get all patches: git format-patch BRANCH
  • get last commit as a patch: git format-patch -1
  • tig is my favorite git client (can do cherry-pick reverts etc and supports bindings)
  • diff between two tags or old tag and current file
git diff v3.12 v4.7 -- src/leanback/java/com/archos/mediacenter/video/leanback/
git show v3.10:src/leanback/java/com/archos/mediacenter/video/leanback/ >
meld ./src/main/java/com/archos/mediacenter/video/leanback/
  • maintain branch up to speed with master before merging i.e v4-jcifsng with v4 (when ready merge back the branch to master)
git checkout v4-jcifsng
git rebase v4 v4-jcifsng
git push -f github HEAD:v4-jcifsng

misc cheat sheet

  • pretty print json: js . < file.json
  • java compilation¬†mvn clean && mvn package -Dmaven.source.skip -DskipTests -Dmaven.javadoc.skip=true && ls ./target/*.jar
  • find some code grep style excluding some files: ag --ignore "*.xml" --ignore "native/" codepage
  • more...