Develop an Android application is a hard work. With large numbers of applications published on Google Play Store, we can have some feedbacks about most common Android Development mistakes. These mistakes are met very often by beginners but not only. Experimented developers can also fall in these traps. This article tries to list the top 10 Android Development mistakes to help you to avoid them. Don’t hesitate to give your top Android Development mistakes in comments.

  1. Not Following Android Guidelines

Google has made a lot of works to reach a high level of maturity for Android OS with a big effort on UI. A lot of Guidelines are available on Android developer site. These guidelines cover design, development, distribution and also marketing. Don’t follow these guidelines would be a big mistake because it implies that your application won’t be fully integrated in the OS and so in the device of your potential users. It will be also bad for your ranking in the Google Play Store and so it will affect your downloads and your possible revenues.

  1. Developing an iOS apps for Android

This point is deeply linked to first point. Indeed, Android has its own UI mechanisms. Adapt an iOS app for Android without taking in consideration Android specificities is a big mistake. Don’t forget it !

  1. Not Supporting Multiple device resolutions

Android is the largest mobile OS in the World. A lot of manufacturers build devices with Android inside. Thus, Android devices have a lot of differences and so you must make a big work to support the maximum of these devices.

To achieve that, Android SDK put a lot of tools between your hands. Use Density-independent pixels (dp) rather than pixels (px). Use resources qualifiers and use also 9-patch drawables. Create layouts that are independent of screen resolutions and can resize well.

You can benefit of Android Emulator to try a lot of different configurations for your applications for free. Think also to use Genymotion to speed up your Android emulations.

  1. Not Using Intents

Intents are at the center of Android OS. They are one of Android’s key components. It’s the best way to pass data between different parts of apps and even better, between different apps on the system.

So, rather than ask for a lot of permissions to your users when they install your application. Use Intents and let the system suggest to users the best installed apps to perform operation.

Imagine your want send SMS from your application. The bad solution would be to requestion the SENS_SMS permissions in your Android Manifest like this :


<uses-permission android:name="android.permission.SEND_SMS" />

Then, write your own code for sending SMS using the SmsManager class.

Even if you explain to you users why you need this permission, for sure they won’t install your app because of this.

The better solution is to use dedicated Intent from your application :


Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("sms:" + phoneNumber));
sendIntent.putExtra("sms_body", x);
startActivity(sendIntent);

 

  1. Not Using Fragments

Introduction of Fragment concept was a very great revolution for Android OS. Fragments help a lot to optimize UI for various screens and are easily manageable and reusable. You can also combine them.

You can think a Fragment like a separate building block with its own (rather complex) lifecycle that exist inside an Activity. Launching a separate activity for each app screen is inefficient. So, you shoud use Fragments whenever possible.

  1. Blocking the Main Thread

Main Thread has a single and simple purpose : processing the user interface operations and keeping the user interface responsive. Your main goal when you process operations in your Android applications is to avoid blocking this Main Thread.

Thus, if Main Thread is blocked for more than 5 seconds in an Activity, OS will display an ANR (Application Not Responding) dialog to users letting them to kill your app. Not the best thing for the user experience !

To avoid ANR, use asynchronous execution for long operations. Android SDK provides a convenient way to achieve that with AsyncTask class implementation. You can also use directly Thread class.

  1. Using Deep View Hierarchy

When you make your layouts in XML, you must avoid to use deep view hierarchy. Inflate deep view hierarchy in an application is very costly operation. So, optimize your layouts and build them to avoid deep view hierarchy when you can.

8.  Not Understanding Bitmaps

Before an image is displayed on an Android screen, it has to be loaded into the memory. Memories of embedded devices are constrained. If you try to display (and so load) very large bitmaps, you could have a bad surprise : an OutOfMemoryError that will cause kill of your application. So, keep this in your mind when you manipulate images.

  1. Not Setting the minSdkVersion to 14

Android 4 has been a very big release for Android. It brought to users and developers most modern applications. In start of 2015, more than 90% of Android users have devices with Android 4 at least. So, avoid some major issues and earn more security by setting the minSdkVersion to 14. It’s time to evolve and say goodby to Android 2.x version.

  1. Not Using new Android Build System

Android Studio became Android official IDE since December 2014. Project structure is entirely based on the new Android Build System that uses Gradle. Like for the Android versions, it’s very important to follow the evolution of Android for the users but also for developers. It’s time for your to migrate to Android Studio and so to new Android Build System. You will need some time to adapt but at the final, it will be better. Note also that Eclipse ADT plugin won’t be maintained.

  1. Extra : Reinventing the Wheel

Yes sir, you’are right, it was a Top 10 but there is a number 11 item ! Like in Java World, Android community has a lot of free and open source components and libraries ready to use. These third-party libraries come with best practices inside and help you to improve your productivity.

So, avoid to reinvent the Wheel for commons operations like : network calls, image loading and caching, JSON parsing or also social login. To achieve this, look at Retrofit, Volley, Picasso, Gson or Jackson. Don’t hesitate also to use frameworks to offer to your applications a robust architecture !

 

Now, you know the Top 11 most common Android Development mistakes. Any new ideas ? Don’t hesitate to leave comments.