Header Ads

Header ADS

Android Development Best Practies

 Learn Android Development:

Let’s explore some of the best practices in designing and developing Android apps.

For starters, when you develop an Android Application, you should prepare it to be run on a wide variety of devices and circumstances.

Every Android device is a family in itself. When one member of the family goes haywire, it means the rest of the family is also likely to be affected.

Did you know that when any single application asks for memory, if there isn’t any free memory, Android will respond by closing other apps so it can provide that memory? Then if the user switches to that application, it will have to be restarted.

When any single application takes up more memory, using more CPU and GPU, or consuming more battery, every other application suffers as a result. And this has the potential to wreck the user experience for the entire device. Hence, performance matters. If you want to learn more about Android performance, start here.


 

Beware of little expenses. A small leak will sink a great ship. — Benjamin Franklin

Here are some of the best practices you should follow when building Android apps:

Use the recommended Android architecture

When you start the Android Development, you do not maintain the coding standard and do not follow any architecture. After adding more and more features, you start facing the following problems:

  • Difficulties in the addition of new features.
  • Introduction of more bugs.
  • Overall slow development.

These problems can be avoided by following the coding standard and following some architecture in your Android project. Learn about the Android Application Architecture from the following resources:

Always maintain the code quality

Quality matters a lot. It’s not only about MVP/MVVM/MVC/etc., but also about each piece of code in each part of your app. Learn about the Android Code Style And Guidelines from here.

Detect and Fix memory leaks in Android App

Check our resources to detect and fix memory leaks:

Use Proguard in your release version

This will remove all your unused code, which will reduce APK size. Master Proguard in Android from here.

Use debugging tools

I highly recommend using Android Debug Database. This library will be your best friend. It is a powerful library for debugging databases and shared preferences in Android applications. It’s a very simple tool for viewing databases and shared preferences directly in your browser. Also, check the new Build Analyzer Tool in Android Studio.

Use strings.xml

Adding text as string resources are always useful in the long-run, especially when support for new languages needs to be added.

Create separate layouts for UI elements that will be re-used

Then use the include tag in xml. Another handy tag is the <merge/> tag. It acts as a pseudo parent and helps get rid of an unneeded root ViewGroup. Read here about it.

Place launcher icons in mipmap-folders

When we build separate APKs for different densities, for the APK of the particular density, the drawable folders for other densities get stripped. This will make the icons appear blurry on devices that use launcher icons of higher density. Since mipmap folders do not get stripped, it’s always best to use them for including the launcher icons.

Use shapes and selectors instead of images as much as possible

Using shapes and selectors will further reduce APK size.

6 comments:

Powered by Blogger.