Posted in Android Experiments, Guides

Android Resources : A Beginner’s Guide

I have been asked this question umpteenth number of times now: Where to begin in Android Development?

Somehow the field of development has garnered a lot of interest in the recent years and I for one appreciate the efforts made by newcomers in trying to grasp as much as possible. The concept of hackathons and start-ups needing beginner level developers has put a meaning to all the work done and prove a worthy motive for developers in wanting to up their game.

I will try my best to provide a flow of learning and the important things every developer should know. This list may not be perfect, far from exhaustive and a little more than a guide. (Disclaimer)

First Lesson Of The Day : Learn to Search! Stack Overflow is your best friend in development! Google Google and Google some more for every problem you have. Mix and combine the answers, copy paste and always make a thorough search before asking your own question. Also when asking a question try to be as specific as possible. Almost everything you are trying to do has had people try it and fail at it. So the answer will be out there somewhere.

Lesson Number Two : Learn to Read Other’s Code. Stuck at implementing a feature? A library guide seems incomplete? Go through the source code, check the flow and see what you missed out. Developers are lazy people when it comes to writing so you’ll seldom find a wiki or guide that is complete or updated (I have encountered so many where they change variable names and forget to indicate so in the wiki.) So read the source. This will not only make you comfortable working on team projects but also give you an idea of how to write code so other’s can understand it easily. Very rarely will you be building a project alone so let’s learn to be a team player 😉

Out of Clever Lessons Now, so back to boring guide for Android. I won’t be providing links to specific tutorials but rather a list of what you should learn (you can go ahead and apply Rule Number 1 to find the tutorials and also because a lot has changed since I first learned Android). You should be able to compare code side by side and judge which is best for your situation, so open a couple of links on every topic and try to decide which one taught you the best and follow it.

The basic lessons to go through (and some not so basic):

  • Learn about the file structure of an Android Project and where everything goes.
  • Learn about basic layouts, toast, Activities and click events. www.raywenderlich.com/78574/androidtutorial-for-beginners-part-1   is a good guide to follow, the whole series is excellent.
  • Learn about intents, extremely useful, sending data through and fro from activities and how to open them.
  • Networking, learn how GET and POST requests are made, through basic HTTTP URL connection then through a networking library like Volley, Retrofit whatever seems best. Almost all applications need to be connected to the net and function in real time.
  • Image handling,take care  not using too much memory and rendering problems. Give Picasso, Glide and Ion a look.
  • Data storage : through shared preferences then local database (both have very different use case) then learn to use an ORM like Sugar or any other that seems better.
  • Fragments – perhaps the most difficult topic there is for beginners, create view pager, and navigation drawers on your own (then use libraries in the future – Neokree, MaterialViewPager)
  • GCM :  Google Cloud Messaging (Advanced): Learn how to do it on your own and then using helpful tech like Firebase. Can also implement the chat application with Firebase as a fun exercise.
  • Being able to integrate available APIs especially Google APIs like Maps. (Advanced)
  • Learn to interact with the camera and the gallery and handle edge cases on devices of various APIs (best to use libraries later for fast and effective implementation)

Once you are through with the basics or want to test your knowledge you can do one or all of the following:

Now for Some Side Tips : (Heads Up on things that become apparent in given time)

  • Android Studio is a genius invention, let it help you as much as possible. Learn about all the shortcuts available for code completion and jumping between files.
  • Do Not and I mean DO NOT stress about the Java implementation of everything. Why did the hardworking chaps in Google do all the hard work if you had to go ahead and spend your head at it. Accept things as they are.
  • A word of advice to Windows users, shift to Linux. You will be doing yourself a favor. So do it before you pull out your hair from all the waiting.
  • Use Genymotion for emulators if real device is unavailable (they are the best option though).
  • Learn Git / Github! The importance of this cannot be stressed enough. If you don’t know how to use them, you are a duck sitting alone outside the party the developer’s world is having.
  • Keep up to date with updates and changes in Android Design Guidelines. Read about the design repository. Some of the best guides available out there : https://github.com/codepath/android_guides
  • Its best to use open source libraries available to build nice features that adhere to Android Design Guidelines. A sample list of libraries for simple features is available at my starred repositories list (too lazy to list them, apologies) Github Profile.

 

I will add resources and guides as I remember them and any suggestion, comments are welcome! Hope it helps some of you out there. Keep coding 🙂

 

Advertisements
Posted in Android Experiments, Uncategorized

Building CyanogenMod 12.1 from Ground Up

This is part of a continued series of my experiments with Android. I am pretty sure my device will just pick up its bags one day and walk away from me in Disney movie style of leaving a cruel master. I better make the most of it till then.

Seeing as I had rooted and explored the world of custom ROM for a while, I decided (well having time to kill decided it for me) that it I should try building the CyanogenMod code from scratch. Download the source and all. I will have to ask for forgiveness right here for messing up any technical terms and process as I am not quite sure of all that happened myself. Having a great mentor always helps and I was fortunate enough to have one who guided me to follow :

https://wiki.cyanogenmod.org/w/Build_for_hammerhead/

A very comprehensive and step by step guide. What all the process entails can easily be read but what I wanted to share were the hair pulling difficulties I ran into.

Half the guide was already covered so I began by downloading the source code which on the first attempt brought down my healthy net connection of ~30mbps to some 18kbps. I had to give up and call it a day. The journey was kick started at 5 in the morning in the hopes of Delhi winters keeping everyone in the hostel asleep leaving the LAN all to myself. I was blessed indeed, it was done in matter of half an hour (all 10 – 12gb of it). I even used and intimidating looking commands for running download on threads (not that scary but I deserve brownie points) .Then came the waiting part – my device needed a lot of food. First a ‘breakfast’ then a ‘brunch’. Aptly named as I had both while waiting for it to finish. But before that how could Java not poke its ever demanding nose in the middle? Apparently I had jdk version 1.8x while it worked only for 1.7x, the agonizing search of removing the latest update, countless ‘jdk already in its latest version useless messages and path variables mess up, it approved my jdk version (Android Studio wasn’t too happy about this downgrade though and it let me know.)   After hours of waiting and watching my terminal light up like in Mr. Robot, I saw the grateful message of a successful build!

Finally the build was flashed onto my device (after getting hysterically lost in the myriad of folders that gets created) and seeing no apparent change, was doubtful about the validity of the whole process. But as pointed out by a helpful soul, seeing my name on the kernel version was worth celebrating and that’s what I did right after 🙂 .

kernel name

Do I wish to carry on and be able to actually make changes to source code? Yes.

Am I sure I will be able to? No.

No step of this journey is without complications and I am not sure how much patience I have. I have come this far, I wish to go forward, only time will tell if I actually do. Fingers crossed.

Things learned today:

  • Think before you decide to mess up your only device.
  • Java has grown too complicated for its own good.
  • Linux/Terminal is GOD.
  • Happiness is seeing your name in the Kernel Version.

 

 

 

Posted in Android Experiments

Flashy Flashy ROMs

It all started with that one crash. New Year, 2016 and WhatsApp apparently couldn’t take the load. It gave in. Frustrations ran high, the impossible had happened. No WhatsApp? How were we supposed to convey our heartfelt greetings to people we probably hadn’t had a human interaction with in a  year? Oh well, my frustration was more rooted in being a developer. Locked out of an application! Oh, the horror! Long story short, a blend of too much ego and an aimless day led to me wiping my phone’s data.

What’s done is done right? Can’t cry over spilled milk and I had always fancied trying on the custom ROM variants of android. (I know many question my even being a developer if I hadn’t done this already. I have one word for you – Laziness) . Luckily I own a nexus 5, Google’s own play toy.  I cant even take credit for all the work I did henceforth.

What ensued was a hurried backup(not much was left to be honest), a quick unlocking of bootloader and then flashing a custom recovery (all child’s play in nexus really). But now came the hard part. Which ROM to choose? Should I leave it to simple stock? Or the evergreen Cyanogenmod 12? And then there’s a tirade of choices by very attractive names. Eeny-meeny-miny-moh.

I tried Stock Rom for a bit, but it didn’t seem worth the effort. And as everyone was using CM, I had to do something different. Typical right? Of all the options available I picked Paranoid Android to be my test mule. Disappointment wouldn’t be the right word to convey it, dissatisfaction it was when I saw it load up. I gave it some 30-45 minutes but I knew this wasn’t it. Hover, peek and pie…eye catching but not long lasting.

Time to be daring, CM 13, here I came. Against all the advice of it being unstable, I installed and ran it and it was just right. Slick animations, minimalistic features, so many options, everything was in place. I paired it up with the Dark Material Theme: https://play.google.com/store/apps/details?id=com.chummy.jezebel.material.dark&hl=en/ and it was like strawberries dipped in chocolate. Just the boot animation! After some tweaks here and there, I was set. But alas, every beautiful story has to have some tragic element or it isn’t complete.

The headphone jack wasn’t working! The music just stopped as soon as they were plugged in. So this is what unstable feels like. After a frantic search and some amount of self cursing, going to CM 12 was the only viable option.  My heart broke a little but the alternative wasn’t a survivable option. CM 12.1. Grudgingly. Stable and all. To be fair, it’s good, like a smaller brother to its newest variant. Though I am missing the multi-window option and cleaner animations, this will have to do till 13 gets more stable. Now as a senior rightly pointed out, if I was worth my metal, I would provide a patch for the bug. I wish I could, but baby steps for now. The future is wide open….

The hardest part of losing your data?  Google keyboard forgetting all your custom words, and I thought we were so close, completing each other’s sentence 😥