Building Android Apps — 30 things that experience made me learn the hard way
Tags: android, androiddev
Published: 2018-11-30 07:41:57

---
title: Building Android Apps — 30 things that experience made me learn the hard way
published: true
description: There are two kinds of people — those who learn the hard way and those who learn by taking someone&rsquo;s advice.
tags: android,androiddev
---

There are two kinds of people — those who learn the hard way and those who learn by taking someone’s advice. Here are some of the things I’ve learned along the way that I want to share with you

 <li id="li">Think twice before adding any third party library, it&rsquo;s a <strong>really</strong> <strong>serious</strong> commitment;</li>
      <li id="li">If the user can&rsquo;t see it, <a href="http://riggaroo.co.za/optimizing-layouts-in-android-reducing-overdraw/" target="_blank"><strong>don&rsquo;t draw it</strong></a>!;</li>
      <li id="li">Don&rsquo;t use a database unless you <strong>really</strong> need to;</li>
      <li id="li">Hitting the 65k method count mark is gonna happen fast, I mean really fast! And <a href="https://medium.com/@rotxed/dex-skys-the-limit-no-65k-methods-is-28e6cb40cf71" target="_blank"><strong>multidexing</strong> can save you</a>;</li>
      <li id="li"><a href="https://github.com/ReactiveX/RxJava" target="_blank">RxJava</a> is the <strong>best</strong> alternative to <a href="https://medium.com/swlh/party-tricks-with-rxjava-rxandroid-retrolambda-1b06ed7cd29c" target="_blank">AsyncTasks and so much more</a>;</li>
      <li id="li"><a href="http://square.github.io/retrofit/" target="_blank">Retrofit</a> is the <strong>best</strong> <strong>networking</strong> <strong>library</strong> there is;</li>
      <li id="li">Shorten your code with <a href="https://medium.com/android-news/retrolambda-on-android-191cc8151f85" target="_blank"><strong>Retrolambda</strong></a>;</li>
      <li id="li">Combine <a href="https://medium.com/swlh/party-tricks-with-rxjava-rxandroid-retrolambda-1b06ed7cd29c" target="_blank"><strong>RxJava with Retrofit and Retrolambda</strong></a> for maximum awesomeness!;</li>
      <li id="li">I use <a href="https://github.com/greenrobot/EventBus" target="_blank">EventBus</a> and it&rsquo;s great, but I <strong>don&rsquo;t </strong>use it too much because the codebase would get really messy;</li>
      <li id="li"><a href="https://medium.com/the-engineering-team/package-by-features-not-layers-2d076df1964d" target="_blank">Package by Feature, not layers</a>;</li>
      <li id="li">Move <em>everything</em> off the application thread;</li>
      <li id="li"><a href="http://developer.android.com/tools/help/layoutopt.html" target="_blank">lint</a> your views to help you optimize the layouts and layout hierarchies so you can identify redundant views that could perhaps be removed;</li>
      <li id="li">If you&rsquo;re using <em>gradle</em>, speed it up anyway you <a href="https://medium.com/the-engineering-team/speeding-up-gradle-builds-619c442113cb" target="_blank">can</a>;</li>
      <li id="li">Do <a href="https://medium.com/the-engineering-team/speeding-up-gradle-builds-619c442113cb" target="_blank">profile reports</a> of your builds to see what is taking the build time;</li>
      <li id="li">Use a <a href="http://fernandocejas.com/2015/07/18/architecting-android-the-evolution/" target="_blank">well known</a> architecture;</li>
      <li id="li"><a href="http://stackoverflow.com/a/67500/794485" target="_blank">Testing takes time but it&rsquo;s faster and more robust than coding without tests once you&rsquo;ve got the hang of it</a>;</li>
      <li id="li">Use <a href="http://fernandocejas.com/2015/04/11/tasting-dagger-2-on-android/" target="_blank">dependency injection</a> to make your app more modular and therefore easier to test;</li>
      <li id="li">Listening to <a href="http://fragmentedpodcast.com/" target="_blank">fragmented podcast</a> will be great for you;</li>
      <li id="li"><a href="https://www.reddit.com/r/Android/comments/2hywu9/google_play_only_one_strike_is_needed_to_ruin_you/" target="_blank"><strong>Never</strong> use your personal email for your android market publisher account</a>;</li>
      <li id="li"><strong>Always</strong> use <a href="http://developer.android.com/training/keyboard-input/style.html" target="_blank">appropriate</a> input types;</li>
      <li id="li">Use <strong>analytics</strong> to find usage patterns and isolate bugs;</li>
      <li id="li">Stay on top of new <a href="https://androidexample365.com/" target="_blank">libraries</a> (use <a href="https://github.com/cesarferreira/dryrun" target="_blank">dryrun</a> to test them out faster);</li>
      <li id="li">Your services should do what they need to do and <strong>die</strong> as quickly as possible;</li>
      <li id="li">Use the <a href="http://developer.android.com/reference/android/accounts/AccountManager.html" target="_blank">Account Manager</a> to suggest login usernames and email addresses;</li>
      <li id="li">Use <strong>CI </strong>(Continuous Integration) to build and distribute your beta and production .apk&rsquo;s;</li>
      <li id="li">Don&rsquo;t run your own <strong>CI </strong>server, maintaining the server is time consuming because of disk space/security issues/updating the server to protect from SSL attacks, etc. Use circleci, travis or shippable, they&rsquo;re cheap and it&rsquo;s one less thing to worry about;</li>
      <li id="li"><a href="https://github.com/Triple-T/gradle-play-publisher" target="_blank">Automate your deployments to the playstore;</a></li>
      <li id="li">If a library is massive and you are only using a small subset of its functions you should find an alternative <strong>smaller</strong> option (rely on <a href="http://developer.android.com/tools/help/proguard.html" target="_blank">proguard</a> for instance);</li>
      <li id="li">Don&rsquo;t use more modules than you actually need. If <em>that</em> modules are not constantly modified, it&rsquo;s important to have into consideration that the time needed to compile them from scratch (<strong>CI </strong>builds are a good example), or even to check if the previous individual module build is up-to-date, can be up to almost 4x greater than to simply load that dependency as a binary .jar/.aar.</li>
      <li id="li">Start <a href="http://developer.android.com/tools/help/vector-asset-studio.html" target="_blank">thinking about ditching PNGs for SVGs</a>;</li>
      <li id="li">Make library abstraction classes, it&rsquo;ll be way easier to switch to a new library if you only need to switch in one place (e.g. <strong><em>AppLogger.d(&ldquo;message&rdquo;)</em></strong> can contain <strong><em>Log.d(TAG, message)</em></strong> and later realise that <a href="https://github.com/JakeWharton/timber" target="_blank"><strong><em>Timber.d(message)</em></strong></a> is a better option);</li>
      <li id="li">Monitor connectivity and type of connection (<strong>more</strong> <strong>data</strong> <strong>updates</strong> while on <strong>wifi</strong>?);</li>
      <li id="li">Monitor power source and battery (<strong>more data updates</strong> while <strong>charging</strong>? <strong>Suspend updates</strong> when<strong> battery is low</strong>?);</li>
      <li id="li">A user interface is like a joke. If you have to explain it, it&rsquo;s not that good;</li>
      <li id="li"><a href="https://twitter.com/danlew42/status/677151453476032512" target="_blank">Tests are great for performance: Write slow (but correct) implementation then verify optimizations don&rsquo;t break anything with tests</a>.</li>