15 Android App Development Hacks For Both Rookies and Experts

Android has been popular choice for global consumers for a while now, thanks to the thousands of devices it powers. A lot of developers are hence attracted towards Android app development. With a basic understanding of the programming language, you can create a working app. But making an app that just does the work won’t get you the results you want. There is a lot more you need to do, to make your app stand out in a crowded market and give your users true value.

Apps that aren’t developed to perfection usually cause problems like sluggish performance and frequent ANRs (App Not Responding). That is a major turn-off for users and they end up giving you one star ratings and a bad review, until eventually, they find a better alternative in the Playstore and abandon your app for good.

To avoid that, you need to develop a cutting edge app that delights users every single time. The key to doing that is in perfecting your basics. Here are few basic things that every developer should take care of when developing an Android application.

Rookies :

1) Knowledge of Language

This is the primary and most important thing you need to master if you wish to develop any application in Android. Java is the primary language for Android development. As a beginner, you need to have a basic knowledge of the language. However, Google has officially added support for Kotlin at the Google IO 2017, so you can now use that as well. A basic understanding of one or both of these languages is essential to begin developing an Android app.

2) Android Studio

Android Studio is a primary IDE (Integrated Design Environment) for Android development. Earlier it was Eclipse using which you could develop Android applications, but in 2015 Google announced Android Studio as its official IDE for Android development.

Android Studio has tools that allow fast development of apps on every type of Android device. World-class code editing, performance tooling, debugging, a flexible build system, and most importantly, an instant deploy system are all the features that do the heavy-lifting, allowing you to focus on building high performance and quality apps.

3) Android SDK

SDK stands for software development kit. Android SDK is a must-have if you wish to start developing with Android. It provides API libraries and developer tools necessary to build, test, and debug apps for Android.

Android SDK includes libraries, documentation, emulator, debugger, sample code and tutorials.

4) Activity/Fragment

When it comes to the development, Activity is the entry point of any Android application. Activity is a single screen which consists of controls related to user interface. Every application must have at least one Activity.

Fragment is a light weight component which is held by Activity. A Fragment can be used in multiple activities. Both Activity and Fragment hold controls like Button, TextView, and RadioButtons etc with which users can give their input or developer can display the information to users.

5) Database

Android supports SQLite to store offline data. SQLite is an open source database and it supports standard relational database features like SQL syntax, transactions, prepared statements etc. It can hold any kind of data like Text, Integer or Real numbers.

When developing with Android, you can use SQLite database just by defining SQL statements for creating and updating the database. By default, the database will be stored in the directory DATA/data/<package-name>/databases/<db-name>

6) Threads

Threads are nothing but background tasks. When you want the app to perform some tasks in the background without interfering with the user interaction, you can use threads. When the app must execute some tasks that don’t need to be seen by the users, or heavy tasks that must run in the background without making the users wait, threads are the right choice. They will perform operations in background and notify the user when the task is completed.

7) Using the Right Query to Search Google

This is one of the most important things to master when you are starting out as a developer or you are starting to develop with new technology. Google is a treasure trove of information and you can find answers, tutorials and shortcuts for pretty much anything you need. To find the right answers however, you need to know how to search. You must enter the right query to elicit the right response from Google.

I have observed that several people try searching for “how to create calculator in android”. Instead, you should search for Buttons which are going to be used for numbers on calculator, search for addition, division or other operations and merge all those things into your query. You can come up with the right query on your own with a little trial and error practice.

That’s for beginner level developers but there are few things that experienced developers too can brush up on, to develop better apps and get an edge over the competition.

Experts :

8) Display Bitmaps Efficiently

“A picture is worth a thousand words.”

Yes, that is true. But as a developer, an image is more than just that. It is a sizable weight on the app that must be handled carefully, so it loads smoothly and doesn’t make the app sluggish. Bitmap, when not managed well, is a major factor responsible for your application’s slow and choppy performance. It can use a lot of device memory and slow down your app.

You need to know how to use bitmap images efficiently. Images can be loaded from network or locally. For local images you cannot do much except try to make image size as small as you can. In some cases you can even avoid images like rectangle, circle, heart and other shapes, instead managing those with xml or vector images.

For network images you can use caching for quick loading. There are many libraries available such as Picasso, Glide and Fresco, using which you can efficiently load images and store them in the cache, so that later on when you want to use that image, you can load it from cache instead of loading it from network all over again.

One more case of efficient image loading presents itself in lists. When you have multiple items on a single page, you can use RecyclerView and load images from network. For instance, say you have 4-5 items visible at a time on a screen and each item consists of an image of size 3MB-4MB. In this case, your screen is going to take up at least 12Mb-20MB of memory for just 4-5 items. Now this is fine if you have a high resolution and very high RAM device but imagine this situation with 480*800 resolution and 512MB of RAM. The device is definitely going to hang and the user is going to uninstall the app.

So the solution could be – instead of loading original images, you can load half sized image or the ideal size required in that RecyclerView item. Assuming the original image is of size 1000*1000, you can load a thumbnail of it to show in RecyclerView, like size of 250*250. Doing so will help you a great deal in improving your application performance.

9) Developing for all devices

Android devices come in many shapes and sizes all around the world. With such high fragmentation, you sure have the potential to get your app a huge audience world over. However, it has some challenges too. For your app to be widely successful on Android, it needs to adapt across all kinds of device configurations. You must account for different languages, screen sizes, and OS versions of the Android platform.

Developers can achieve this by maintaining consistent density for each device type and by using multiple layouts. Maintaining density allows you to define different margins, padding, text size etc for different type of devices. To give full support of your application to wide area of devices and tablets, you can have separate layouts for device and tablet.

10) Choose Libraries Efficiently

The first thing all developers tend to do as soon as a requirement arrives from the client, is to search for a library that can get the job done quickly. Indeed, it is wise to get help from 3rd party libraries as they help get the task done faster. But there are a few precautions that must be taken when using third part libraries. You must check for issues that could be caused because of that library. check for the feasibility of customization. What if the client requirement changes or in next the next version of the application, the client asks you to change the design? Will those libraries still work? Probably not when it is related to UI. Those are the questions you need to answer before choosing a library. If the library is related to architecture or core functionality however, it will work in 99% cases.

Before choosing a third party library, a good developer would perform a thorough research, and check for any known issues of that library, check forks and stars on github that the library has received, check the response rate of the developer who developed that library and take other cautionary steps. Once you are satisfied with what you see and are sure that the library is good to go, you can use it for your app.

11) Proguard

Proguard is a free Java class file shrinker, obfuscator, optimizer and preverifier. You can use it to make your APK files as small as you need. Proguard detects and eliminates unused fields, classes, attributes, and methods from your app. It also optimizes the bytecode and removes any unused code instructions. It renames the remaining fields, classes, and methods using random short names.

As you know well, Android is an open-source platform and anyone can reverse engineer your APK and steal the code. Proguard makes your app difficult to reverse engineer by obfuscating the code. It does so by changing its name and identity, making it much harder to decompile.

Enabling Proguard:

Android{

    .

    .

    .

    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
}

12) Architecture

Developing large scale applications with large teams requires a deeper understanding of the different architectures available and the ability to choose the best one for a specific project. There are various different architectures available in the market and choosing one that’s perfect for your requirement can take a lot of careful planning.

Years of experience writing code for Android have taught me that implementing a feature or solving a problem just for this point of time is not enough. Over time, your app goes through a number of change cycles and features addition/removal. If your app is not designed properly with separation of concern, making changes to the app in future can cause major challenges. Choosing the right architecture is not just about MVP/MVVM/MVC, but much more than that. It is about writing high quality code in each part of your app.

13) Testing

The criticality of repeated testing cannot be stressed enough. You must test your app at every stage to sort out problems as they arise, check for snags and eradicate any bugs no matter how small. It is a good idea to run unit tests on the JVM, as it’s much faster than running them on the Android device itself or an emulator. You can use Robolectric if you require any Android dependencies, or use Mockito if you need to mock some objects while testing.

Testing becomes an essential part when you are working on large scale applications. Imagine you have over twenty modules and you have to change just one of them. After changing that module, you cannot manually test all other modules, as that will take a huge amount of time. Each time you make changes, you cannot keep testing the entire app and that is why it is always helpful to write Testcases.

Always be sure to include functional UI tests. These tests check the functionality of your app from the user’s point of view by launching it to test its functionality, almost as if in real time. You can even use Android Instrumentation if your application is not interacting with other applications, as this way, it runs only with your app. You can use UIAutomator if there is any interaction with other apps.

14) Subversion(Git)

While this particular skill may not be required often, you will normally want to use some sort of version control system. You need not be an expert at managing merge conflicts, but you must know the basics of creating and using a repository as well as committing and pushing changes.

It will not directly help you with coding but it will definitely help you improve workflow and collaborate with a large team. Even if some of your team members are working remotely, Subversion will help you work as one.

15) Contribute to the Community

Though this is not strictly related to development, but contributing to community helps you increase your knowledge and share your expertise with like minded people. Yes, start contributing to the community in whatever way you can. Start writing blogs, it will help you improve your writing skills as well as research skills. It will help you strengthen your grasp of the subject before you begin explaining anything to others.

Another benefit of contributing to the community is that you stay updated and never miss out on the latest happenings in the world of development. There are so many ways in which you can contribute. Write your own blogs, create own library and help other developers through StackOverflow or Quora. My own experience says you will get lot of knowledge by connecting to the community.

Having over four years of experience, I have my own blog Androidgig.com and 12000+ reputation on Stack Overflow. It gives me immense pleasure to do what I am doing and share my experiences with those eager to learn and share. This keeps me motivated to innovate, learn new things and do more.

I hope the above tips help you become a better developer and create memorable apps that you are proud of. I wish you all good luck and welcome you to share your experiences and thoughts with me.

Ravi is an Android developer with MoveoApps, who loves exploring ReactJS and React Native among other technologies. An out-and-out Google fan, he closely follows all their updates and events. The movie buff never misses catching up on the latest releases during weekends with his friends. Find him on Twitter: @ravi_rupareliya