Android Apps Develop Fast(er) and Easier (saves 30 min daily)

Gopi Krishna
10 min readNov 14, 2018
Develop Android Apps Fast(er) and Easier (saves 30 min daily)

The current article will make android app development faster by around 30 minutes when followed completely. Using most useful Android Studio plugins, Android adb terminal shortcuts, Android Build time optimisation…Below says how to do it.

In case you didn’t read my first article Code Clean up with Kotlin please read for code cleanup.

We always want to write most efficient code.
but what most doesn’t do is Efficiency of writing such kind of code ( time taken)

Topics

  1. Terminal Shortcuts ➿( saves 4 min )
  2. Android Studio Plugins ( saves 5 min )
  3. Jumpcut (saves 3 min)
  4. BetterTouchTool (saves 2–3 min)
  5. Git Commands with Android Studio ( saves 5–6 min)
  6. Reduce Build time ( saves a lot 15–20 min)
  7. Android Studio must remember shortcuts (saves 2–3 min)
  8. File Templates ( saves a lot 10 minutes )
  9. Third Party Libraries & Others
Develop Android Apps faster and save time

Using MAC OS as reference to below, feel free to change based on Operating System

1. Terminal Shortcuts

There are many things which we can do it better & faster through terminal commands but main problem is typing big commands .

Typing big commands

Also when building huge project through Android Studio Green button, it takes lot of RAM also causes it to stuck few times. So building apps using default terminal, Studio terminal or iTerm2 is better.

We usually do following for App like Install , Uninstall , Start , Stop , Clear Data, Navigate folders, Check crash logs & more .

Use in terminal following commands
bld
// to Build with Debug flavor then install App then start it
bld<space>c // clean ->Build with debugFlavor->install->start it
bldu // to Uninstall App then Build with Debug flavor then install App & then start it
ins <pathToApk.apk> // Uninstall App then install with apk path
upg <pathToApk.apk> // Upgrade app without uninstalling earlier one
upglatest // Upgrade app with latest updated apk in current folder & Starts the app. Useful when apk is build but forgot to connect device.
logs // print only crash logs of the device
gitrev // revert your last commit from your current Git branch
gitcurrent // copies current Git branch name to your Clipboard
gitdelbranch // deletes Git local branches of given pattern like abc
uns // to uninstall ; clr // for clear data ; stp // force stop app
sta // to start App
opent <fileName> // open file in TextEdit rather than vim
l // cd.. ; ll // cd ../.. ; lll // cd ../../..

If u r working on multiple apps simultaneously instead of changes .bash_rc file every time. u can do below ( This will change only in that terminal tab)

updateappid com.mycurrentotherapp.def // update other appId
updatemainactivity com.mycurrentotherapp.def.MainActivity
updatebuildtype iR // optional use this only when u want to change build variant type , here changing it to installRelease from Debug
printvariables // will print current state of above variables.
After doing updateappid ... u can use above commands bld , bldu , sta ... which will work on new app instead of old defined in bash_rc

Other helpers in terminal to make it faster ( using Android Studio terminal)

option(alt) + delete // deletes a word ( not a letter )
fn + left/right arrow // moves to start/end of current line
esc + wait 50ms + B // moves cursor a word backwards
esc + wait 50ms + F // moves cursor a word forward
c // clear screen o // to open finder window in current path
use l's to navigate back (l cd.. ll cd../.. )
copypath // copy current path

To make 👆 work, Create a file in ~/.bash_profile or use ~/.bash_rc file & copy paste 👇 & use src ~/.bash_profile or src ~/.bash_rc to load

2. Android Studio Plugins

Few plugins which help immensely to made development faster.

a. AndroidDrawableImporter with this , just select a ZIP which has pngs in all resolutions like hdpi, xhdpi … , it auto imports to Android Studio in single click. Also u can import Android Material Icons in a single click

b. Biu can compress/convert to webp any image in single click. (right click on image -> Compress/ convert to Webp ) {powered by tinypng.com}

c. Android Code Generator with this, u just write the layout xml then u can generate Activity , Fragment , Adapter code in a single click in java. FindViewById for id generation in java n kotlin.

d. Custom Postfix Templates this adds custom postfix templates which are very useful. U can create name.isNullReturn & tab converts to if(name == null) Log.d("TAG", "name is null); return;

e. GsonFormat paste a json this will create classes & Inner classes for you with @SerializeName as well for Java . For Kotlin use JsonToKotlinClass

f. Jimu Mirror updates layout, animation changes in real-time as you code ( like React ). See this video.

f. Now Automatic Parcelable generation is present in Studio(3.0+) itself in contextual action 💡 for both Java & Kotlin.

There are others like Adb Wifi, KeyPrompter (for prompting keyboard shortcuts) , AdbCommander, RainbowBrackets, AceJump (easy caret movement), String Manipulation (to multiple CASES) . By doing above u’ll feel like

3. Jumpcut — Multi copy tool

The most & the frequent thing every developer does is copy & paste . There are few problems with it

a. Only single copy allowed i.e copy then paste works fine but copy1 copy2 copy3 then paste1 paste2 paste3 doesn’t work , which is needed many times

b. I closed my web page some 30 min back , I copied something what is it? i.e you need the list of all the items which are copied, so that u can use it later.

c. Copy source can be anything from Slack, Browser to Android Studio… So I need a system wide utility not a plugin in Android Studio …

Above all problems is solved by simple software like Jumpcut for MAC & ClipJump for windows. For convenience keep Command + Shift + V as shortcut for paste popup. Copy u can do normally.

Jumpcut paste popup

4. BetterTouchTool

One more frequent thing every one does in Android Studio is Switch between code tabs, Close tabs , Go back to last edited location… So install BetterTouchTool with this u can do literally, any thing on Mac as easy as

Using Tip Tap Left/Right ( 1 finger fix) to go to left / right tab . TipTap Right ( 2 finger fix) to close current tab. Snapping windows similar to Windows OS, Text replacement & many more

See following articles for more clarity TipTap gesture , https://appleinsider.com/articles/18/07/20/bettertouchtool-is-the-app-the-macbook-pro-with-touch-bar-needs

5. Git Commands with Android Studio

Many people has habit of commiting & pushing using terminal. It’s not bad but its slow & there are few problems with it . It’s very easy & saves lot of time in Android Studio.

a. Check files status with git statusthen git add then git commit& git push . Instead do it in single key

b. Conflict Resolution is very easy with 3 way merge. UnStashing u can check changes before applying in Studio

c. Studio provides Reformatting code , Organize Imports , Check Todo’s , Perform code analysis & many more which cannot be done normally using command line unless there is a pre-hook commit script …

6. Reduce Build time

There are few ways to reduce build time. See 👇

a. For testing always use build variant which is debug with minifyEnabled false & shrinkResources false as minify & shrink takes adds lot to build time.

b. Add following to gradle.properties if not added to make build faster

org.gradle.daemon=true
org.gradle.parallel
=true
org.gradle.jvmargs
=-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.caching
= true
org.gradle.configureondemand
=true
android.enableBuildCache
=true

c. For your test build variant/product flavour do following to decrease time

customBuildFlavor {
minSdkVersion 21 // makes build time slightly faster
aaptOptions {
cruncherEnabled = false
}
dexOptions {
preDexLibraries = true
}
resConfigs("en", "xxhdpi") // specify a default language & resolution for faster packing of build
}

d. This is slightly hacky but works , if your company is using lot of GitHub tracking libraries like DexCount ( for counting methods ) , other Functional testing libraries like Jacoco , Spoon etc . Comment out all (which are not directly effecting the App code ) apply plugin & its references but don’t Git push file to your server branch .

Just use the above to build, you will be surprised to see build time will decrease by 30 seconds on every build.

7. Android Studio must remember shortcuts

Few shortcuts which every developer must know. Avoid using Double Shift in Android Studio as much as possible (bcoz it is slow) , instead use appropriate shortcut of each. For convenience change shortcuts to below in Android Studio->Preferences -> Keymap ->Search -> Add keyboard shortcut

. Open any file ( Command + Shift + R )
. Find in path ( Command + Shift + H ) { for string search like "abc" }
. Close All tabs ( Command + Shift + W )
. Recent files ( Command + E )
. File Structure ( Command + O ) { Go to method name inside a file, no Command + F here, which is slow}
. Navigate -> Declaration ( F1 ) // go to declaration of variable or method call hierarchy
. Navigate -> Back ( F2 ) // go back to last cursor position
. Navigate -> Forward ( F3 ) // go forward from last cursor position
. Run -> Step into (F5) // Debugging go into the method
. Run -> Step over (F6) // Debugging go to next line of the method
. Run -> Resume Program (F8) // Debugging stop at next debug point
Optional Good to have :
. VCS -> Git -> Commit (Command + Shift + L)
. VCS -> Git -> Pull (Command + Shift + ;)
. VCS -> Git -> Unstash (Command + Shift + ")

If you see carefully above most of above shortcuts u can use just with your left hand (single ✋). Most of the times we want see declaration of variable or call hierarchy of a method use F1 for it. Also to go 🔙 to last cursor location use F2. Go forward use F3. For touch bar mac laptops see Display function keys for certain apps to make function keys default in touch bar mac. You can convert above to gestures using point 4 BetterTouchTool as well.

8. File Templates

Instead of creating same files like RecyclerViewAdapter , Fragments , DialogFragments , Dialogs … again & again. Add it as a template saves lots of time, frustration & will create it in a single click.

9. Others

adb shell 'am start -a android.intent.action.VIEW -d "company://product/capture?a=1&b=2&data={'abc':'first','def':'second'}"'

Good requires motivation, Great requires obsession. You should be very conscious of every time saving trick to achieve fastness

Conclusion

Hopefully, this article helped by showing many ways to make Android Development faster. I have given all my information which I’m using from few years. If you find this article useful Please 👏 👏

Please Clap

📝 Read this story later in Journal.

🗞 Wake up every Sunday morning to the week’s most noteworthy Tech stories, opinions, and news waiting in your inbox: Get the noteworthy newsletter >

--

--