Gotchas and Lessons Learnt - Android Development

11:42 AM


Starting Android development might mean taking a new leap into a new area for many. But Android can be very interesting to work on. Only at the end of completing an app, would someone wish that they knew about some essential android information at the very start!

These are a few tips can help you on your first Android venture. So here goes:


Running and Debugging applications

I would always recommend using a device rather than an Emulator. One of the reasons being:

Running an application on an Emulator is very slow and it takes minutes to just deploy the app onto the emulator. On the other hand, deploying it on the real device is fast, efficient and , HEY!, the end product is going to be on a real device. Why waste time on an emulator (unless of course you don’t own one).

If you want to know how to do this procedure or you have issues with detecting your devices to debug your app, follow this link:
http://seventhsoulmountain.blogspot.com/2014/01/usb-debugging-for-android-applications.html

Know how your application looks on different phones

In case you overlook this feature, I just want to remind you that there is a cool feature on ADT where you can find how your app looks on different densities of screens.



You can choose any of these different devices to check how your app looks like on these devices.

Alternatively, you can click on “Preview All Screens” to see all the screens fitted to your screen.

Note: If you get an error as such





…then simply click on the green android image on top and select an API Level lower than 19 (API 18 or below).





Source Files missing

Sometimes when you are debugging and you are faced with the scenario below. You don’t even have to get into the debugging, just jump into an Android class and you may find this.

All you’re Android source files are missing. So what should you do?





This basically means that the classes haven’t been attached to its source. Clearly, Eclipse does not know where the source code for the dependent jars are.

To overcome this problem, this solution can work. Click on the “Attach Source” button. Direct the folder path to wherever the Android SDK’s sources folder is, and select the specified API level folder (android-15) (You can also just only give the path to the sources folder without specifying the api level).




Eclipse crashes and you lose data. What next?

Be prepared to run into this circumstance at any time! Eclipse is very unreliable because it loses your code that you spent time and energy on. It can happen when your power goes, when your computer heats up, when there’s less memory on your machine etc.


You see something similar to the one below



So what can you do to prevent this?

  1. You should always create backups. 
  2. Use a version control system (SVN, Git etc)

…BUT you haven’t, and now you are helpless. What can you do to RECOVER them at this point?


There is one thing you can do. Though at times you may not be able to recover your files or you may not get ALL of your code, it is still worth the try!

   1. On the file, right click and click on “Replace with” and click on “Local History”



   2. Select the last that has been in the history and click on “Replace"



Do not lose your Keystore!

Don’t forget to save your Keystore file! This is what you will need to sign your application if it has to go on Google Play. If you have misplaced your keyfile, you cannot upload an updated version of your app. You will have to upload it again! 

Google doesn’t store your private key because it doesn’t have any use with it. So there is absolutely no reason and no way Google can restore something they don’t own.

So... Create as many backups as you can.


Know about Android UI Components before you start Coding!

I made a grave mistake once about overlooking the List Menu in Android. I went about implementing layouts that looked like them. The worst part was writing the functionality for them. It took up a lot of time, effort and at the end, when a co-worker pointed out what I was doing wrong, I was frustrated. That is one mistake I will never make again!

UI Resources designing and creation

When designing UI resources for your app, you should always have in mind that android devices come in various densities and sizes. When creating an icon or an image, you should create them in appropriate sizes so that your images dont look small or take up less space on your HDPI screen, when it fits properly on your MDPI. 

Take a look at this documentation: It will help you get a clear idea about it: 
http://developer.android.com/design/style/devices-displays.html


Libraries to use in your App

I have basically not been in need to use a third party library in an app that I was developing. But there are plenty and some of them are given below. I have heard alot about these libraries and I'm sure it can help you.

ActionBarSherlock - This allows you to easily develop an application with an action bar for every version of Android from 2.x and up

SlidingMenu - An Android library that allows you to easily create applications with slide-in menus.


Some tools to use in your App

Especially when you are planning to make your app reach out to a wider audience around the world, you should be very responsible about how your application responds to them. Which means, you should identify any crash scenarios that may arise on different types of phones. 

Crashlytics - this is a really cool plugin that you can use in your app which notifies you of all the crashes that occur in their devices as a result of using the app.

Matt - this tool helps you identify possible memory leaks and reduces your memory consumption

Something in your XML file doesn't work as expected

You do some new change to your XML file and it doesn't work as expected. CLEAN REBUILD! You spend hours trying to find out what went wrong and later you realize a simple Clean Build fixed your issue. Not only goes for XML, but also your source code. 


Help is just a click away 

Android Developer Documentation is really good! All you need to know is in there!

------------------------------------------------------

Yeah so folks, this is all I have for now, and maybe if I have more things coming to my mind about my lessons learnt on Android, we shall meet again. 

Happy Coding! :)

You Might Also Like

1 comments

  1. Hey....This is really nice..Thanks for sharing the content with us!!

    Want to know the latest and hottest trends on Twitter, then come up with the amazing app

    https://itunes.apple.com/us/app/tweet-cinema/id866641393?mt=8

    Believe me guys this is one of the best app to remain always connected with the twitter and the most interesting part, it is available absolutely free of cost!!

    Love to hear from you more about these apps!!

    ReplyDelete