06 September 2015

Android Adventures - Part 01


Mobile is already a big thing and I've long craved for the opportunity to write some mobile code. I've never worked with Android Studio (Idea IntelliJ, actually), nor have I built applications with Gradle, but most of all I've never actually tried writing an application for a mobile device.

So what I did was what any sane developer with 10 years of experience would do.

Well, not really.

Facebook and Android

Facebook have recently modified the API that Android applications use to query their graph database. Essentially what happened is that an Android mobile app could no longer retrieve the full list of friends for a given user, unless they've given permissions to this app. This has proven the end for many contacts synchronization apps, including the one I was using - HaxSync


Being a law-abiding citizen, who is always paying his taxes, updating his Facebook status hourly and regularly paying unreasonable amounts of money of Nexus phones I felt the righteous anger after not being able to see the funny faces of my friends every time they call me on the phone.

They left me no choice. I was going to revive the HaxSync project and do my best to restore the functionality that was taken from me.

Lessons learned

So far I've spent 2 days trying to compile the code. Me being a total lamer aside, here are the things I am no longer ignorant about:
  • Gradle is fun - it is, in my humble opinion, an interesting combination of the convention over configuration principles in Maven, the freedom of writing completely unreadable code and being able to sneakily plugin just about any dangerous plugin you can think of. To be fair, with such a large user base, any problem in Gradle could be solved with the first result in Google Search. Lazy developing for the win!
  • The mysterious "R" package / class is nothing but an auto-generated resource file. If you are having issues with it missing and breaking your compilations just make sure you do not have any other issues in your project (since they would prevent IntelliJ from generating it and thus would cause unnecessary noise). Or if the issue persists you could go to File / Invalidate caches & restart.
  • Following the standard Gradle source tree standard could save you a lot of problems. My thanks to Eranga Bandara for helping up with gradleizing the original project.
  • Having a Gradle wrapper, although seeming ludicrous to a person who dislikes committing binaries and tying up the build to a specific version of Gradle, is actually very useful, especially if you want to quickly integrate your project with Travis CI.
  • Android is nice, Android API versioning is not.

Wish me luck

If you want to help me out you are more than welcome. 

I will try to get this small project running before November, 2015, but as my Java Certification Trials have proven - The only way to make gods laugh is to make plans for the future.