Android Dev — The Good Parts

Prashast Rastogi
AndroidPub
Published in
4 min readJul 22, 2018

Its been 2 years since I wrote my first code on Android, probably the best decisions in my professional career.

I distinctly remember we ( bunch of my friends) started working on an idea called “GreenBoard”, being a mobile first concept we had to take up Android Development. And since then there has been no turning back.

In initial days, my friends were the only mentors for me. It was a tough period and I made a lot of mistakes . There were times when we reached the end result but were skeptical about the methodologies and architecture used and knew soon enough it will break. Soon I met a couple of experienced and talented Android Developers who taught me the RIGHT WAY TO DO ANDROID.

This was the part when I corrected myself and learnt from the mistakes made earlier. It has been some time and now I wish to give everything back to the community the same way they gave it to me.

I’ll be sharing some keynotes that I learnt through out this journey. This will help beginners learn Android a more faster way and not to repeat the mistakes that I once did.

1. GIT — Your Host for tonight!

Git will help you manage your code on different machines and share with developers around the world even if they have a 777 permission of source code.

I remember the first time when I had to merge my code to a repository , that was probably my toughest day. I always had a backup of my project due to lack of confidence on git.

But with time I learnt using it and it solved my complex life. Now I can write any code any time and push it to any workflow.

Out of curiosity I learnt how GIT worked internally and it amazed me. Here is a cheatsheet to GIT which I stuck on my desk in early days.

2. No Language Bar

Add multiple languages in your app like a pro.

Always remember to extract strings in the project. No harcoded strings should ever be set free.

This was the biggest problem I faced while refactoring one of my project. I didn’t realise when my project scaled and there were thousands of strings which were yet to be extracted. Eventually I had to go after every class and XML and extract them.

As a result I learn’t another cool stuff, LINT CHECK

3. Structure your code with Lint

Running lint will help you find warnings in the project. It will notify about the unextracted Strings , mismanaged indentation , wrong Java Doc formats, Warnings in XML — unclosed tags, missing hints, unwanted attributes, etc

4. Use 3rd party libraries wisely

Earlier I liked creating everything from scratch instead of using some library which has already solved my use case. Invest more time in architecting your project rather than focusing on the atom.

How I end up choosing libraries?

Find repositories that cover the use case and check whether development is still under progress or has it been abandoned by the developer. Next, count the stars — that will surely help you understand the likeability of the repository in the community.

Definitely read the source code and see how the developer solves your problem. There will be cases where library will cover multiple use cases, there you can bring out the code and try using them in your project.

Disclaimer: Please check for registered permissions of the repository whether it allows sharing and reusing code.

5. Proguard is a necessity

Size matters!!

Proguard helps minifying the size of APK. That’s not it — Obfuscation!

Reverse Engineering is a problem that every developer must have faced. By the concept of RE you can get access to project files and code underlying the APK

So proguard helps in both of them. Few points to keep in mind what all to include in proguard file —

Remember not to include classes used as network object else server response will be distorted. Find files to be obfuscated of 3rd party libraries used in project. Also there are multiple attributes that one should be aware of while obfuscating files, for eg. ignorewarnings, dontwarn, keep, keepattributes, keepclassmembers, dontnote, keepclasseswithmembernames, etc.

I’ll include more points with time. Stay tuned.

Cheers!!

--

--

Prashast Rastogi
AndroidPub

Android Engineer @ LocoNav. Ui enthusiast. Full Stack Developer. Changing world in every "mobile" way!