<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adam Bennett</title>
    <description>The latest articles on DEV Community by Adam Bennett (@ditn).</description>
    <link>https://dev.to/ditn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F5215%2F177d9664-de6c-4727-be7c-b537b6f89088.jpg</url>
      <title>DEV Community: Adam Bennett</title>
      <link>https://dev.to/ditn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ditn"/>
    <language>en</language>
    <item>
      <title>Migrating to Downloadable Fonts on Android</title>
      <dc:creator>Adam Bennett</dc:creator>
      <pubDate>Thu, 28 Jun 2018 10:21:02 +0000</pubDate>
      <link>https://dev.to/ditn/migrating-to-downloadable-fonts-onandroid-4fjb</link>
      <guid>https://dev.to/ditn/migrating-to-downloadable-fonts-onandroid-4fjb</guid>
      <description>&lt;p&gt;This is a rehost of the article I wrote for the &lt;a href="https://medium.com/blockchain-engineering" rel="noopener noreferrer"&gt;Blockchain Engineering blog&lt;/a&gt;. You can find the original article &lt;a href="https://medium.com/blockchain-engineering/migrating-to-downloadable-fonts-on-android-49f0a1c3d79b" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;At Blockchain, we have many mobile users in bandwidth constrained environments such as developing countries. As such keeping the app small and lightweight is a priority for the Android team. Smaller app sizes increase both installs and conversion rates - important metrics for any mobile-focused company. We've used various techniques over the last year to prevent bloat to the app including shrinking what few PNGs we have, using &lt;code&gt;VectorDrawables&lt;/code&gt; at every possible opportunity, and aggressively leveraging ProGuard.&lt;/p&gt;

&lt;p&gt;In previous versions of the app, we bundled three fonts and relied on a third party library named &lt;a href="https://github.com/chrisjenx/Calligraphy" rel="noopener noreferrer"&gt;Calligraphy&lt;/a&gt; to render the fonts across all API levels for us. Calligraphy has served us well, and for a long time was the only viable solution for font application. But the library is yet another third-party dependency and hasn't been updated in nearly a year.&lt;/p&gt;

&lt;p&gt;One downside of using a third-party solution is that Blockchain does not have full control over these fonts - Google could break how the library works at some point in the future. The other downside to this approach is that the necessary bundled fonts take up space. Thankfully, this is no longer required.&lt;/p&gt;

&lt;p&gt;Android Oreo added &lt;a href="https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts" rel="noopener noreferrer"&gt;downloadable fonts&lt;/a&gt;, which allows apps to request typefaces from a font provider and load them at runtime instead of loading them from the apps assets folder. This has added benefits in that it reduces the chances of an app installation failing randomly, and multiple apps requesting the same font can share these resources.&lt;/p&gt;

&lt;p&gt;As of Support Library 26.0.0, Google backported the font provider, and this has given us a native (or close to native) solution all the way down to API 14, which is beyond what we need here at Blockchain.&lt;/p&gt;

&lt;p&gt;Adding a downloadable font is simple - head to the Layout Editor, select &lt;code&gt;fontFamily&lt;/code&gt; -&amp;gt; &lt;code&gt;More Fonts&lt;/code&gt;, and choose whatever you might need. Android Studio then imports all of the necessary files, and also adds entries to the Android Manifest and generates the relevant XML files declaring the font used, and how to retrieve it from the font provider.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AilZTsWot9dskcEjm." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F0%2AilZTsWot9dskcEjm." alt="Selecting fonts in the Layout Editor"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We did find a slight oddity as to how this system worked. Google claims that this gives you access to every typeface on &lt;a href="https://fonts.google.com/specimen/Montserrat?selection.family=Montserrat:300,600" rel="noopener noreferrer"&gt;fonts.google.com&lt;/a&gt;. In practise, however, we could only get two variations of Montserrat via the Android Studio interface - regular and bold. We make heavy use of Montserrat Light plus Montserrat Semi-Bold, so this was not ideal.&lt;/p&gt;

&lt;p&gt;In searching for a solution, we found the fonts we wanted via fonts.google.com and noticed that the URL parameters included a weight (300 for light, 600 for semi-bold). Simply adding these parameters into the fontProviderQuery allowed us to download them without issue, although Android Studio did then highlight the query as having no exact match. We found that this particular Lint error could be safely ignored, as the correct weights of font were loaded successfully on every test device.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;app:fontProviderQuery="name=Montserrat&amp;amp;amp;weight=600"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We use a couple of custom Views which could not be themed this way directly, so we also had to programmatically download the Typeface and apply this at runtime, rather than using XML or Styles. For this, we used Kotlin and higher order functions to request fonts asynchronously, before delivering the result to the caller.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Taking advantage of the flexibility of Kotlin, we also added an Extension Function that applies the newly loaded Typeface directly to a TextView. We use this in a couple of places to dynamically change the font on a TextView depending on whether or not it was the last selected View.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Lastly, we found that the speed of the loading process occasionally caused Views to "pop" as the font was applied and the View bounds adjusted. This was easily fixed by adding a local cache of Typeface objects keyed to a CustomFont object, which encapsulates the query necessary to load the font. This made programmatically loading fonts functionally instant in most cases.&lt;/p&gt;

&lt;p&gt;After all that, we managed to reduce the APK size from 7.7MB to 6.8MB - an 11% reduction - with the download size reducing from 5.4MB to 5.0MB - a 7.5% reduction. This is a substantial win for relatively little work, and makes a huge difference to end users. If you want to view the changes, feel free to check out the feature PR &lt;a href="https://github.com/blockchain/My-Wallet-V3-Android/pull/896" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you found this interesting, &lt;a href="https://boards.greenhouse.io/blockchain/jobs/240440" rel="noopener noreferrer"&gt;we're currently hiring engineers&lt;/a&gt; for the Android team.&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>a11y</category>
    </item>
    <item>
      <title>A Closer look at Slices on Android</title>
      <dc:creator>Adam Bennett</dc:creator>
      <pubDate>Thu, 31 May 2018 10:32:21 +0000</pubDate>
      <link>https://dev.to/ditn/a-closer-look-at-slices-onandroid-193l</link>
      <guid>https://dev.to/ditn/a-closer-look-at-slices-onandroid-193l</guid>
      <description>

&lt;p&gt;In the lead-up to Google IO 2018 and after peering into the Android P Alpha release, some people noticed a mysterious new "Slices" class within the P SDK docs. There was a lot of speculation as to what Slices actually did, and Sebastiano Poggi at Novoda did a great &lt;a href="https://blog.novoda.com/android-p-slices-missing-documentation-part-1/"&gt;deep-dive&lt;/a&gt; into what was known at the time.&lt;/p&gt;

&lt;p&gt;But now that IO has passed, what have we learned about Slices, how can we leverage them in our apps, and why would we even want to? To answer that question, let's start with App Actions.&lt;/p&gt;

&lt;h2&gt;Actions Everywhere&lt;/h2&gt;

&lt;p&gt;App Actions, also known as Actions on Google, are part of a new framework that allows developers to integrate their app fairly deeply with Google Assistant, Search, the Play Store and wherever else Google wants in the future. Whilst App Actions are not yet even in developer preview, we know a little about them from the overview &lt;a href="https://developer.android.com/guide/actions/"&gt;website&lt;/a&gt; and various &lt;a href="https://www.youtube.com/watch?v=lu3L6DxUBRA"&gt;talks at IO&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There is a lot that you can do with App Actions such as interacting directly via Google Assistant and registering custom Intents, but for now we'll focus on how they act as a bridge to Slice functionality.&lt;/p&gt;

&lt;p&gt;At a high level Google has defined a growing &lt;a href="https://developers.google.com/actions/reference/built-in-intents/"&gt;set of Intents&lt;/a&gt; with their own data schemes. Developers then expose content within their app to these Intents, and offer functionality via deep-linking. For the purposes of this article, we'll be looking at the &lt;code&gt;actions.intent.GET_CRYPTOCURRENCY_PRICE&lt;/code&gt; Intent, which has got me rather excited for obvious reasons.&lt;/p&gt;

&lt;p&gt;Intents such as &lt;code&gt;GET_CRYPTOCURRENCY_PRICE&lt;/code&gt; can be triggered by what Google are confusingly calling &lt;em&gt;Semantic Intents&lt;/em&gt; - which are generally spoken-word or typed queries to the Google Assistant or Search. With our example Intent, a Semantic Intent might be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What's the current price of bitcoin in dollars?&lt;/li&gt;
&lt;li&gt;What's ETH doing today?&lt;/li&gt;
&lt;li&gt;How much is Dogecoin worth?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For an app to handle such queries themselves would be extremely difficult, but instead Google can recognise the intention of the user and then deliver results in a format that we can then process in some way:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "cryptocurrency": {
    "name": "string"
  },
  "exchange": {
    "name": "string"
  },
  "target monetary spec": {
    "currency": "string",
    "valid_at": "date string (ISO 8601 format)"
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the example above finding the name of the cryptocurrency is fairly easy, but the fiat currency is often implicit - I would assume that Google are using device locales or geographic location to infer the most likely local currency. Much of speech is implied, and Google handles this difficult task for you in many cases.&lt;/p&gt;

&lt;p&gt;This is all well and good, but how do we register our app to take advantage of these Intents?&lt;/p&gt;

&lt;h2&gt;Enter actions.xml&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;actions.xml&lt;/code&gt; is a new file that you would include in your app which defines a mapping between App Actions Intents and the URIs that you wish your app to handle. Within this file, you can essentially pull values out of the App Action schema defined by the Intent and then insert them into whatever URL format your app accepts:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;  &lt;/div&gt;

&lt;p&gt;Note that this implementation is pulled from the IO session on App Actions - there's no documentation yet and it may well not be correct when App Actions launch proper. As such this is somewhat speculative.&lt;/p&gt;

&lt;p&gt;This file is then scanned by Google on uploading an APK (or app bundle) to the Play Store, and the supported app actions are stored in a database. Users who then trigger the Semantic Intent associated with your app can then potentially see a suggestion to download your app in the Play Store (as an example, with more to follow in the future). It goes without saying that this can give you an edge in terms of discoverability.&lt;/p&gt;

&lt;h2&gt;Enter Slices&lt;/h2&gt;

&lt;p&gt;From here, you can handle the URL/deep link as you would any other within your app by registering an Intent Filter and pointing towards your class extending &lt;code&gt;SliceProvider&lt;/code&gt;:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;  &lt;/div&gt;

&lt;p&gt;Within this class, you then override &lt;code&gt;onMapIntentToUri&lt;/code&gt; to return a properly formed non-null URI from the supplied Intent, and then you can start actually building your first Slice.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;onBindSlice&lt;/code&gt; is the next method that needs overriding, and it's here that you can extract more information from the URI (in this case, the cryptocurrency and fiat currency codes) and actually setup your UI.&lt;/p&gt;

&lt;p&gt;Slices are somewhat unique in that you can't merely inflate your own Views - Google instead are providing a host of preset &lt;a href="https://developer.android.com/guide/slices/templates"&gt;templates&lt;/a&gt; into which you can pass data (Strings, images, icons etc) as well as a handful of interactive features such as progressbars, sliders and toggles. This may be an issue for some but it means that all Slices will be visually consistent, and Google says this means that they're easily portable to new UI formats, devices, and dare I say it - operating systems.&lt;/p&gt;

&lt;p&gt;Creating this UI is done via the &lt;code&gt;ListBuilder&lt;/code&gt; class, which allows you to add rows of information; each row having methods such as &lt;code&gt;setTitle&lt;/code&gt;, &lt;code&gt;addEndItem&lt;/code&gt;, &lt;code&gt;setPrimaryAction&lt;/code&gt; etc. You can also create a grid layout of sorts here. You also set a period of validity for the data, which in this example is infinite but should probably be quite short.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;  &lt;/div&gt;

&lt;p&gt;This simple &lt;code&gt;ListBuilder&lt;/code&gt; statement creates a neat little Slice that looks like this in the Slices demo app, which for now is the only way to view them:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5Vz2fZqC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1600/1%2AlLDpJ_x8Qqt7Cf74bIKgDQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5Vz2fZqC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1600/1%2AlLDpJ_x8Qqt7Cf74bIKgDQ.png" alt="A Slice! Essentially an on-demand, highly portable widget and gateway to your app."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Loading Content&lt;/h2&gt;

&lt;p&gt;This is all well and good, but you don't necessarily have price information to hand - you'll probably want to fetch an up-to-date quote from the network. However in &lt;code&gt;onBindSlice&lt;/code&gt;, we see some documentation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;onBindSlice should return as quickly as possible so that the UI tied to this slice can be responsive. No network or other IO will be allowed during onBindSlice. Any loading that needs to be done should happen in the background with a call to {@link ContentResolver#notifyChange(Uri, ContentObserver)} when the app is ready to provide the complete data in onBindSlice.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This, like the Slice templates, is another sensible API design choice from Google. Effectively, Google are running StrictMode around this particular function. The solution here is pretty simple - provide a "loading" placeholder UI Slice, load your data asynchronously, and then call &lt;code&gt;notifyChange&lt;/code&gt; as required.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;  &lt;/div&gt;

&lt;p&gt;&lt;code&gt;notifyChange&lt;/code&gt; causes &lt;code&gt;onBindSlice&lt;/code&gt; to be called again, so in our naive example we store the update cryptocurrency price in a nullable property called &lt;code&gt;bitcoinPrice&lt;/code&gt;, and decide whether or not to display a placeholder slice based on the property's null status. There are definitely better ways to do this, but this works for our purposes.&lt;/p&gt;

&lt;p&gt;As far as next steps are concerned, you would most likely want to add some interactivity to the Slice, or at the very least link back into your app. Opening an Activity is achieved with &lt;code&gt;setPrimaryAction&lt;/code&gt; which takes a &lt;code&gt;SliceAction&lt;/code&gt; object - pretty much just a wrapper with a &lt;code&gt;PendingIntent&lt;/code&gt;, icon and description.&lt;/p&gt;

&lt;p&gt;Slices that are fully interactive accept a &lt;code&gt;PendingIntent&lt;/code&gt; via &lt;code&gt;setInputAction&lt;/code&gt;, for which you then register a &lt;code&gt;BroadcastReceiver&lt;/code&gt; and handle accordingly.&lt;/p&gt;

&lt;h2&gt;Sign me up!&lt;/h2&gt;

&lt;p&gt;If this all sounds great to you, Android Studio 3.2 Canary offers a handy quick-start for implementing Slices. &lt;code&gt;New -&amp;gt; Other -&amp;gt; SliceProvider&lt;/code&gt; leads you to a wizard that adds the necessary manifest entries for you, and allows you to personalise some things such as the URLs that you want to handle.&lt;/p&gt;

&lt;p&gt;Bear in mind that none of the App Actions stuff that actually links your Slices to Google's indexing is available yet, nor will an app with a "valid" &lt;code&gt;actions.xml&lt;/code&gt; compile for now.&lt;/p&gt;

&lt;p&gt;Nevertheless, you can test out your Slices via the command line + &lt;a href="https://github.com/googlesamples/android-SliceViewer/releases/download/1.0.0-alpha1/slice-viewer.apk"&gt;Slice Viewer APK&lt;/a&gt; in the meantime until App Actions goes live. I'd encourage you to have a bit of a play with it and watch the Slices IO session, which really convinced me that Slices were a powerful feature worth investigating.&lt;/p&gt;

&lt;h2&gt;Great, but why?&lt;/h2&gt;

&lt;p&gt;With the example I've run with here, users who have the app installed who search for "what is the bitcoin price" or even potentially just "bitcoin" will see a Slice in Search or the Google Assistant. This can quite easily drive more engagement into your app, and I'm sure you can think of lots of interesting examples for your particular app or company. Interactivity is a great use case too, offering rapid access to features for users who may not have realised that such features existed. It's these little surprise-and-delight features that we all love in our apps, and that personally I enjoy implementing the most.&lt;/p&gt;

&lt;p&gt;At the same time, adding App Actions on it's own can give you an edge in the Play Store listings, which can be extremely valuable. It's unclear from Google quite what they plan to do with this stuff (again, App Actions aren't yet even in developer preview), but the potential is there for driving more interaction with your app across multiple input types and devices.&lt;/p&gt;

&lt;p&gt;For a more complete example, check out my &lt;a href="https://github.com/ditn/ReceiveOnly/blob/feature%2Fslices_demo/slices/src/main/kotlin/uk/co/adambennett/receiveonly/slices/CryptoPriceSliceProvider.kt"&gt;test project repo&lt;/a&gt; where there's a slightly rough but concrete implementation. For Google's own documentation, check out their getting started guide &lt;a href="https://developer.android.com/guide/slices/getting-started"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If this was helpful to you please leave some applause, and I'm more than happy to receive feedback. Finally, if you want to work on this sort of stuff, &lt;a href="https://www.blockchain.com/careers/index.html"&gt;we're hiring&lt;/a&gt;!&lt;/p&gt;


</description>
      <category>android</category>
      <category>google</category>
      <category>kotlin</category>
      <category>developerpreview</category>
    </item>
    <item>
      <title>Conditional statements in Builders in Kotlin</title>
      <dc:creator>Adam Bennett</dc:creator>
      <pubDate>Thu, 26 Apr 2018 11:01:16 +0000</pubDate>
      <link>https://dev.to/ditn/conditional-statements-in-builders-inkotlin-525p</link>
      <guid>https://dev.to/ditn/conditional-statements-in-builders-inkotlin-525p</guid>
      <description>&lt;p&gt;At Blockchain, we recently updated our Android app to use more robust push notifications via &lt;a href="https://firebase.google.com/docs/cloud-messaging/"&gt;FCM&lt;/a&gt;, notifying users of BTC received to their wallets. &lt;/p&gt;

&lt;p&gt;As you might expect, we added a custom vibration pattern to our notifications, but this presented a slight problem. As it turns out, devices where Android ≤4.3 will throw an errant &lt;code&gt;SecurityException: Requires VIBRATE permission&lt;/code&gt;. This is easily fixed, but how do we do this in an idiomatic way?&lt;/p&gt;

&lt;p&gt;One suggestion was to try/catch firing the notification — this is obviously quite nasty and is a raw deal for users on old devices. The simple way would be to this would be to turn the builder into a local &lt;code&gt;val&lt;/code&gt; and then simply amend the builder separately:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This is absolutely fine but it breaks up the Builder pattern and we can do better. What if we could put this logic in-line?&lt;/p&gt;

&lt;p&gt;Using extension functions, we can extend &lt;code&gt;NotificationCompat.Builder&lt;/code&gt; and create a new function that accepts a predicate, and calls either one function or another depending on the outcome. Taking advantage of function literals with receivers (ie, &lt;code&gt;A.() -&amp;gt; A&lt;/code&gt;), we can ensure that the functions to be triggered are both existing public methods of &lt;code&gt;NotificationCompat.Builder&lt;/code&gt; and return the &lt;code&gt;NotificationCompat.Builder&lt;/code&gt; object itself.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This allows us to do this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Much cleaner, and doesn’t break the Builder flow. This ternary function seems pretty useful, can we generify it for use with any Builder class? Of course:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;So this worked great and I felt pretty good about it for about 15 minutes, and then I realised that infact, Kotlin already had me covered:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;code&gt;apply&lt;/code&gt; is in-fact what exactly I was looking for, as &lt;code&gt;this&lt;/code&gt; is both it’s receiver and return type. Sheepishly, I corrected my fun-but-not-idiomatic code and pushed it to origin.&lt;/p&gt;

&lt;p&gt;Still, this was a fun learning experience that I thought I’d share. Kotlin and it’s high-order functions, including those built-in, are incredibly powerful and I love finding new applications for them.&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>designpatterns</category>
    </item>
    <item>
      <title>Best iOS resources for an experienced dev?</title>
      <dc:creator>Adam Bennett</dc:creator>
      <pubDate>Fri, 18 Aug 2017 08:36:09 +0000</pubDate>
      <link>https://dev.to/ditn/best-ios-resources-for-an-experienced-dev</link>
      <guid>https://dev.to/ditn/best-ios-resources-for-an-experienced-dev</guid>
      <description>&lt;p&gt;I'm an experienced Android developer, but I'm looking at branching out into iOS development too. Has anyone here done the same? What are some good resources for learning iOS? What challenges did you face when you started working on iOS?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>android</category>
      <category>ios</category>
      <category>career</category>
    </item>
    <item>
      <title>Synthetic Accessors in Kotlin</title>
      <dc:creator>Adam Bennett</dc:creator>
      <pubDate>Mon, 10 Jul 2017 14:03:12 +0000</pubDate>
      <link>https://dev.to/ditn/synthetic-accessors-in-kotlin</link>
      <guid>https://dev.to/ditn/synthetic-accessors-in-kotlin</guid>
      <description>&lt;p&gt;So this is a pretty nerdy blog and should be a quick one, but I just wanted to share my findings.&lt;/p&gt;

&lt;p&gt;As you may know, &lt;a href="https://medium.com/thoughts-overflow/effects-of-javas-synthetic-accessor-methods-in-android-bb67b3bac22e" rel="noopener noreferrer"&gt;accessing private methods or fields in Java&lt;/a&gt; from nested or anonymous inner classes results in the creation of &lt;a href="https://developer.android.com/training/articles/perf-tips.html#PackageInner" rel="noopener noreferrer"&gt;synthetic accessor methods&lt;/a&gt;. Jake Wharton’s &lt;a href="http://jakewharton.com/exploring-java-hidden-costs/" rel="noopener noreferrer"&gt;talk on Java’s hidden costs&lt;/a&gt; is worth a watch here if you have no idea what I’m talking about.&lt;/p&gt;

&lt;p&gt;These synthetic accessors are generated by the compiler and have big drawbacks on Android — potentially adding hundreds if not thousands of unnecessary methods across a project, each contributing to hitting the dex limit. Direct access to these methods or fields can also be up to 7 times faster than using a getter, which is nothing to sniff at.&lt;/p&gt;

&lt;p&gt;Consequently at Blockchain we use the &lt;a href="https://android.googlesource.com/platform/packages/apps/Launcher3/+/master/src/com/android/launcher3/util/Thunk.java" rel="noopener noreferrer"&gt;Thunk&lt;/a&gt; annotation to signal to developers that we’ve changed the scope of a field or method for the sake of avoiding synthetic accessor creation. There’s also a handy inspection built into Android Studio to highlight cases that you might have missed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2ARZhTqGk5RSrDWEKdxANeSQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2ARZhTqGk5RSrDWEKdxANeSQ.png" alt="I highly recommend enabling this particular inspection."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is pretty well known. But is this an issue in the new hotness, Kotlin?&lt;/p&gt;

&lt;p&gt;In short, yes.&lt;/p&gt;

&lt;p&gt;Ultimately this shouldn’t be too surprising: Kotlin compiles down to the equivalent Java bytecode, so this is indeed a problem here too. I figured it would be but I wanted to check, so here’s what I found:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SyntheticAccessorTest&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;args:&lt;/span&gt; &lt;span class="nc"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;someClass&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;SomeClass&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;SomeInterface&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;doSomething&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;printSomething&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;

            &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;doSomethingElse&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;})&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;printSomething&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Something"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nf"&gt;SomeClass&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="nl"&gt;listener:&lt;/span&gt; &lt;span class="nc"&gt;SomeInterface&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;SomeInterface&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;doSomething&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;doSomethingElse&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have a simple test class which invokes the constructor of another simple class and takes an anonymous implementation of an &lt;code&gt;interface&lt;/code&gt;. In one of the callbacks, we invoke a function which is &lt;code&gt;private&lt;/code&gt;, in another we increment a counter which is also &lt;code&gt;private&lt;/code&gt;. Unfortunately because of this, the resulting &lt;code&gt;.class file&lt;/code&gt; will absolutely have synthetic accessor methods, and once we look into it, it’s easy to see why.&lt;/p&gt;

&lt;p&gt;In Android Studio, if we select &lt;code&gt;Kotlin Bytecode&lt;/code&gt; and then &lt;code&gt;Decompile&lt;/code&gt;, we get this Java (I’ve simplified this a bit for readability):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SyntheticAccessorTest&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
   &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

   &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@NotNull&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;SomeClass&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SomeInterface&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
         &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;doSomething&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;SyntheticAccessorTest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;printSomething&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
         &lt;span class="o"&gt;}&lt;/span&gt;

         &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;doSomethingElse&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;var1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
            &lt;span class="nc"&gt;SyntheticAccessorTest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;SyntheticAccessorTest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
         &lt;span class="o"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;});&lt;/span&gt;
   &lt;span class="o"&gt;}&lt;/span&gt;

   &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;printSomething&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;var1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Something"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
   &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we then decompile the file with &lt;code&gt;javap -p -c SyntheticAccessorTest.class&lt;/code&gt;, we then get this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SyntheticAccessorTest&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]);&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;printSomething&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;SyntheticAccessorTest&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;access$printSomething&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SyntheticAccessorTest&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;access$getCounter$p&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SyntheticAccessorTest&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;access$setCounter$p&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SyntheticAccessorTest&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And there they are: it’s these &lt;code&gt;access$&lt;/code&gt; methods that are the problem. In fact we get two for the &lt;code&gt;counter&lt;/code&gt; field; one for &lt;code&gt;set&lt;/code&gt;, one for &lt;code&gt;get&lt;/code&gt;. You can easily see how this starts to add up quickly in an Android project.&lt;/p&gt;

&lt;p&gt;If we change both &lt;code&gt;counter&lt;/code&gt; and &lt;code&gt;printSomething()&lt;/code&gt; to &lt;code&gt;internal&lt;/code&gt;, we get this instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SyntheticAccessorTest&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;getCounter$Test_Project&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;setCounter$Test_Project&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]);&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;printSomething$Test_Project&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;SyntheticAccessorTest&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nl"&gt;Code:&lt;/span&gt;
       &lt;span class="o"&gt;[...]&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Better. But what is interesting here is that whilst we lose the synthetic accessor for &lt;code&gt;printSomething()&lt;/code&gt;, we still get two methods for setting and getting the &lt;code&gt;counter&lt;/code&gt; property. This is due to Kotlin automagically adding getters and setters to properties, and indeed if we check the generated Java, we see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;getCounter$production_sources_for_module_Test_Project&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;setCounter$production_sources_for_module_Test_Project&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;var1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;var1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whether or not this seems unnecessary is up to you. In most Java classes you’d likely have written setters and getters anyway, so you haven’t really gained any unneeded methods in many situations. However in this case as the property is being accessed inside the parent class: these are obviously superfluous. Applying the same inspection to the equivalent Java code results in just 3 methods; two fewer than Kotlin.&lt;/p&gt;

&lt;p&gt;If this is a huge concern for you there’s a simple fix; add the &lt;code&gt;@JvmField&lt;/code&gt; annotation to the property and the getter/setter won’t be generated (thanks to Kirill Rakhman for the heads up).&lt;/p&gt;

&lt;p&gt;So yes, you do need to be careful about accessing private functions in Kotlin for the same reason as you do in Java, and there appears to be a hidden cost in simply using properties. Sadly there isn’t yet an inspection for this yet, but I’m hoping that IntelliJ/Google will add this fairly soon. In the meantime, check your code carefully if the dex method count is something you worry about.&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>java</category>
    </item>
    <item>
      <title>Ensuring code quality onÂ Android</title>
      <dc:creator>Adam Bennett</dc:creator>
      <pubDate>Fri, 16 Jun 2017 16:25:08 +0000</pubDate>
      <link>https://dev.to/ditn/ensuring-code-quality-onandroid</link>
      <guid>https://dev.to/ditn/ensuring-code-quality-onandroid</guid>
      <description>&lt;p&gt;Everybody likes to think they output good quality code, but how do you ensure that whilst making sure that your team members are on the same page? Here’s a few techniques that I’ve used over the years. This blog is mostly aimed at team leads or seniors working with 3+ people, but some may tips be useful for single contributor/OSS projects.&lt;/p&gt;




&lt;h1&gt;
  
  
  Formatting &amp;amp; Consistency
&lt;/h1&gt;

&lt;p&gt;Personally, I’m super pedantic about the formatting in my code. Even just errant or missing spaces a bugbear, but thankfully there are tools to prevent this sort of general annoyance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code styleÂ rules
&lt;/h2&gt;

&lt;p&gt;The first step is to make sure that your team are all reading from the same hymn sheet. Some may be more strident about consistency than others, but at the very least you should choose a code style and stick with it. For many, just using the default IntelliJ/Android Studio code style is enough; many use the Google Java code style.&lt;/p&gt;

&lt;p&gt;Regardless of whether you use the default or some crazy custom settings, why not simplify everyone’s lives and bundle your settings with your project’s git repo? This saves you digging around IntelliJ’s preferences when onboarding a new team member, and provides one less excuse for those not adhering to standards.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2A-xD77ULjNPo84ullru4C4Q.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2A-xD77ULjNPo84ullru4C4Q.gif" alt="Nobody wants this toÂ happen."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bootstrap
&lt;/h2&gt;

&lt;p&gt;Better yet, why not have your project install your code style for you? This idea is shamelessly lifted from the excellent &lt;a href="https://github.com/kickstarter/android-oss" rel="noopener noreferrer"&gt;Kickstarter app&lt;/a&gt;, where they have a &lt;code&gt;scripts&lt;/code&gt; folder which contains a bash file which sets up the project for youâ€Š–â€Šcopying across their code style xml, removing the default file header, running &lt;code&gt;git submodule update --init --recursive&lt;/code&gt;, and even checking for the presence of their keystore and warning the user if it’s not found.&lt;/p&gt;

&lt;p&gt;We’ve made use of this idea on the &lt;a href="https://github.com/blockchain/My-Wallet-V3-Android/blob/master/scripts/bootstrap.sh" rel="noopener noreferrer"&gt;Blockchain Android app&lt;/a&gt;, and it makes onboarding new developers and contributing to the open source repo much easier. Alternatively you could probably write this as a Gradle build script too if that’s more your thing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Android Guidelines
&lt;/h2&gt;

&lt;p&gt;IntelliJ/Android Studio’s formatting rules can only get you so farâ€Š–â€Šwhat about formatting for RxJava operators? Resource naming conventions? Do you want your team using conditionals without braces?&lt;/p&gt;

&lt;p&gt;For this, I recommend that you write or fork a more complete style guide, such as the excellent one by the &lt;a href="https://github.com/ribot/android-guidelines" rel="noopener noreferrer"&gt;Ribot&lt;/a&gt; team. This leaves no ambiguity as to how you expect your team to write your code, and I leave &lt;a href="https://github.com/ditn/android-guidelines/blob/master/project_and_code_guidelines.md" rel="noopener noreferrer"&gt;a version of it that I’ve edited&lt;/a&gt; pinned to Chrome to refer to whenever I forget something silly. Recently we started using Kotlin in production but I found the official guidelines a bit lacking, so &lt;a href="https://github.com/ditn/KotlinStyleGuide" rel="noopener noreferrer"&gt;I wrote a basic guideline for that too&lt;/a&gt;. Link to these guidelines in your &lt;code&gt;README.md&lt;/code&gt; and never have an argument about line wrapping again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enforcement
&lt;/h2&gt;

&lt;p&gt;So you’ve done all of this but you want to make sure that people are actually sticking to the rules you’ve laid outâ€Š–â€Šhow do you go about it?&lt;/p&gt;

&lt;p&gt;Thankfully there are tools out there which allow you to validate this stuff. &lt;a href="http://checkstyle.sourceforge.net/" rel="noopener noreferrer"&gt;Checkstyle&lt;/a&gt; is the most commonly used tool for this; just ensure that the &lt;code&gt;checkstyle&lt;/code&gt; task is being run in CI (you do have CI, don’t you?) and that it fails the build when necessary.&lt;/p&gt;

&lt;p&gt;You may find initially that getting builds to pass is pretty painful, as you might have to edit some rules to enforce your own style choices. Consequently, we’re not currently using it at Blockchain, but I would 100% use it on a new project if given the chance.&lt;/p&gt;




&lt;h1&gt;
  
  
  Robustness
&lt;/h1&gt;

&lt;p&gt;What good is pretty, consistent code if it breaks or can’t be maintained? How do you make sure that your code is relatively robust?&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;Testing on Android used to be an absolute nightmare. Nowadays, it’s comparatively simple assuming you’ve chosen a sensible architecture and maintain reasonable design choices such as inversion of control. Consequently there’s no excuse for not having tests: they promote confidence in your code, catch edge cases you might not have designed for (if the tests are well written) and it’s just generally gratifying to see your coverage go up.&lt;/p&gt;

&lt;p&gt;You should run unit tests on CI whenever code is pushed to a remote branch. This helps catch bugs during the development process and ensure that nothing too scary gets pushed to &lt;code&gt;master&lt;/code&gt;. In that vein, we also have it set up so that a different CI server runs integration tests on creating a pull request into either &lt;code&gt;develop&lt;/code&gt; or &lt;code&gt;master&lt;/code&gt;. As these are slower, we don’t want necessarily want them running on every push.&lt;/p&gt;

&lt;p&gt;We also make use of &lt;a href="https://help.github.com/articles/about-protected-branches/" rel="noopener noreferrer"&gt;protected branches&lt;/a&gt;, which prevents a lazy developer from force pushing to &lt;code&gt;master&lt;/code&gt;, and won’t allow us to merge PRs until all checks have passed (unit &amp;amp; integration tests, plus code coverage via Jacoco + &lt;a href="https://coveralls.io/" rel="noopener noreferrer"&gt;Coveralls.io&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;For a testable app, you’ll want to be using some form of architecture convention, such as MVP, MVVM, MVI, Redux or whatever your preferred way is. This helps separate the Android layer (which is very difficult to test) from the core business logic, and if done sensibly can make a huge difference in making the app more testable. We use &lt;a href="https://github.com/blockchain/My-Wallet-V3-Android/tree/master/app/src/main/java/piuk/blockchain/android/ui/base" rel="noopener noreferrer"&gt;MVP&lt;/a&gt; at Blockchain (although you can see here that we’re moving away from MVVM).&lt;/p&gt;

&lt;p&gt;We also make heavy use of &lt;a href="https://google.github.io/dagger/" rel="noopener noreferrer"&gt;Dagger2&lt;/a&gt;, which has a pretty steep learning curve but makes handling the creation and injection of your dependencies much easier, and therefore makes testing simpler. I would definitely recommend spending some time learning how to use it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AysGRkJrlpqZCDyhaykrv4A.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AysGRkJrlpqZCDyhaykrv4A.jpeg" alt="Credit to Ribot for this excellent diagram."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Again this is where having a company guideline linked in your repo is probably the simplest way to make sure the team is adhering to your architecture. Referring back to Ribot, their style guide also includes an awesome &lt;a href="https://github.com/ribot/android-guidelines/blob/master/architecture_guidelines/android_architecture.md" rel="noopener noreferrer"&gt;architecture diagram&lt;/a&gt; as well as their reasoning as to why they chose the layers and structure that they did. If you’re thinking about switching to something like MVP, write out a similar diagram as you may find it helpful, then get coding a simple example for the team to refer to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bugs
&lt;/h2&gt;

&lt;p&gt;Of course, testing only gets you so far; there will be plenty of bugs that you might not have spotted. Here again, there are tools to give you a hand.&lt;br&gt;
Lint is a big one, and this can be run from the command line (and therefore CI) and output the results for you. You can also customise your lint rules should you so want, and again bundle them in your repo.&lt;/p&gt;

&lt;p&gt;You should aim to reduce the number of lint errors that you see at build time, but for years this was quite difficult to enforce as either a single error would fail your build, or you simply added &lt;code&gt;lintOptions.abortOnError false&lt;/code&gt; to your build.gradle. Mercifully, the Android team has added a &lt;a href="https://developer.android.com/studio/write/lint.html#snapshot" rel="noopener noreferrer"&gt;tool to allow you to set a baseline&lt;/a&gt; and save that in your repoâ€Š–â€Šmeaning that from that point forward, any new errors results in build failures.&lt;/p&gt;

&lt;p&gt;The downside is that Lint only runs when you’re generating a release build, and when you’re under pressure to get a build out to QA or what have you, that might not be the best time to have to fix errors. The solution is simple: add a Lint task to your CI process (are you noticing a pattern yet?). It’s as simple asÂ &lt;code&gt;./gradlew lint&lt;/code&gt;, although saving the output is going to vary based on your CI provider.&lt;/p&gt;

&lt;p&gt;Another excellent tool is &lt;a href="http://findbugs.sourceforge.net/" rel="noopener noreferrer"&gt;FindBugs&lt;/a&gt;, which spots all sorts of issues related to security, performance and general code correctness. It’s a fantastic tool which I’m ashamed to admit I haven’t added to CI yet, but is run manually at least once a month to get a feel for general code correctness. I recommend it thoroughly. Again, add any custom filters to your repo so that everyone has access.&lt;/p&gt;

&lt;h2&gt;
  
  
  Crashes
&lt;/h2&gt;

&lt;p&gt;With all the tools and caution in the world, sometimes bugs will slip through the net. How do we handle those?&lt;/p&gt;

&lt;p&gt;Firstly, do not rely solely on the Google Play Store. Bug reports have to be manually uploaded by users, which in my experience means that less that 0.1% of all crashes are ever reported. This will change due to Google’s new stance on the matter (where everything is reported automatically), but you still don’t want to rely on the Play Store dashboard for your bug hunting.&lt;/p&gt;

&lt;p&gt;For that I have always used &lt;a href="https://try.crashlytics.com/" rel="noopener noreferrer"&gt;Crashlytics&lt;/a&gt; which is exceptional. I’ve also used Firebase’s solution which is so-so, but Firebase/Google now recommend that you switch to Crashlytics anyway, which will be incorporated into their metrics in the coming month. If you don’t currently have a crash reporting library; get this added now and prepare to be humbled.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kotlin
&lt;/h2&gt;

&lt;p&gt;It wouldn’t be an Android blog without some mention of Kotlinâ€Š–â€Šbut in all seriousness; by some estimates 60% of crashes in Android apps are Null Pointer Exceptions. Kotlin’s nullable type handling helps reduce that dramatically, and should be considered for the improvement it can make to your app’s reliability (and overall developer productivity &amp;amp; happiness).&lt;/p&gt;

&lt;p&gt;One caveat to this is that many static analysis tools don’t currently work with Kotlin, and Lint itself has less checks. I expect this will change in the next six months though, as the language explodes in popularity and Google throws their weight and expertise behind it.&lt;/p&gt;




&lt;h1&gt;
  
  
  Other tools
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.sonarqube.org/" rel="noopener noreferrer"&gt;Sonarqube&lt;/a&gt; is another well-established tool that attempts to provide you with an overview of your code’s quality. It gives you a measure of technical debt, code coverage, code smells and a bunch of other useful metrics. I can’t speak to it’s quality, but it’s something that I’d like to integrate at some point.&lt;/p&gt;

&lt;p&gt;Of course, your main line of defence in ensuring that good code goes out to your consumers is peer review. Much has been written about how to go about reviewing the code of others so I won’t say much here, other than you absolutely need to make pull requests a key part of your programming workflow if you don’t already. Linus’s Law states:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Given a large enough beta-tester and co-developer base, almost every problem will be characterized quickly and the fix obvious to someone.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or more succinctly: given enough eyeballs, all bugs are shallow. Although there won’t be many eyes if you work by yourself, giving yourself a “cooling off” period between writing a PR and merging it can be invaluable too.&lt;/p&gt;

&lt;p&gt;This workflow also allows you as a team lead to keep an eye on the performance of each team member and help out those that are struggling, allows Juniors to learn from the Seniors and should be a level playing field for all where ideas and notes are exchanged, not judgements levied.&lt;/p&gt;




&lt;p&gt;You may not want all to use all of the ideas I written about here, but I’m hoping that some of you found this useful. Go forth and create beautiful, consistent, reliable code!&lt;/p&gt;

</description>
      <category>android</category>
      <category>codequality</category>
      <category>architecture</category>
      <category>testing</category>
    </item>
    <item>
      <title>What I look for in a Junior Android Dev</title>
      <dc:creator>Adam Bennett</dc:creator>
      <pubDate>Fri, 28 Apr 2017 18:59:56 +0000</pubDate>
      <link>https://dev.to/ditn/what-i-look-for-in-a-junior-android-dev</link>
      <guid>https://dev.to/ditn/what-i-look-for-in-a-junior-android-dev</guid>
      <description>&lt;p&gt;About a week ago, someone on &lt;a href="https://www.reddit.com/r/androiddev/" rel="noopener noreferrer"&gt;/r/androiddev&lt;/a&gt; asked the question &lt;a href="https://www.reddit.com/r/androiddev/comments/66obt0/what_are_the_thing_that_every_junior_android/" rel="noopener noreferrer"&gt;“What are the things that every Junior Android Developer should know?”&lt;/a&gt;. Being the kind of guy that I am, I was browsing the subreddit at work (whilst &lt;a href="https://xkcd.com/303/" rel="noopener noreferrer"&gt;compiling&lt;/a&gt;, obviously) and got an answer in early which people seemed to like a lot. So this is mostly just me expanding on my points.&lt;/p&gt;

&lt;h1&gt;
  
  
  Skillset
&lt;/h1&gt;

&lt;p&gt;If you’re looking to come onboard as a Junior, there’s a few things that I’d expect you to know. None of them particularly in-depth, of course (not in a patronising way), but for me to see that you’re interested in the field and learning as much as you can, I’d want to see at least some low-level knowledge in the following areas:&lt;/p&gt;

&lt;h2&gt;
  
  
  The Activity Lifecycle
&lt;/h2&gt;

&lt;p&gt;It’s Android. There’s no getting away from it. These events are absolutely crucial to developing an app that doesn’t crash when you accidentally rotate the screen because you’re browsing in bed.&lt;/p&gt;

&lt;p&gt;On first glance this diagram doesn’t look all that friendly:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ACGGROXWhl8dTko1GdDeFsA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ACGGROXWhl8dTko1GdDeFsA.png" alt="lifecycle"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But in reality, I don’t expect a Junior to know the whole thing off by heart. As long as you’re aware of &lt;code&gt;onCreate&lt;/code&gt;, &lt;code&gt;onPause&lt;/code&gt;, &lt;code&gt;onResume&lt;/code&gt; and &lt;code&gt;onDestroy&lt;/code&gt;, what causes them and their implications, then you’re off to a good start. If you’re a bit unsure, check out the &lt;a href="https://developer.android.com/guide/components/activities/activity-lifecycle.html" rel="noopener noreferrer"&gt;official docs&lt;/a&gt;. If you give an example as to how the lifecycle could cause a memory leak, I’d be mightily impressed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Android Components
&lt;/h2&gt;

&lt;p&gt;The building blocks of any app. There’s only 4 major components: &lt;a href="https://developer.android.com/guide/components/activities/index.html" rel="noopener noreferrer"&gt;Activities&lt;/a&gt;, &lt;a href="https://developer.android.com/guide/components/services.html" rel="noopener noreferrer"&gt;Services&lt;/a&gt;, &lt;a href="https://developer.android.com/guide/topics/providers/content-providers.html" rel="noopener noreferrer"&gt;Content Providers&lt;/a&gt; and &lt;a href="https://developer.android.com/guide/components/broadcasts.html" rel="noopener noreferrer"&gt;Broadcast Receivers&lt;/a&gt;, and each has an important part to play in creating an Android app. You won’t necessary need all of them in a single app (for instance, in my professional career I’ve never needed to write a Content Provider), but I’d still 100% like to see that a candidate can explain roughly what each one does and what they might use one for.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Aqnf9ecWmWjEv5jhy2qgf1Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Aqnf9ecWmWjEv5jhy2qgf1Q.png" alt="android-components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Persistence Options
&lt;/h2&gt;

&lt;p&gt;There’s a handful of options for persisting data on Android, and each has their own pros, cons and use-cases. There’s a &lt;a href="https://developer.android.com/guide/topics/data/data-storage.html" rel="noopener noreferrer"&gt;helpful guide&lt;/a&gt; on the Android Developer website which explains how to use each type, and again I’d want to see if you can recall them and in broad strokes what you might use each type for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Networking
&lt;/h2&gt;

&lt;p&gt;This is a biggie and there’s an awful lot to know, but for someone wanting to go for a Junior position there’s only a couple of things that I’d deem essential.&lt;br&gt;
Basic REST knowledge is a must, and if you can’t make a simple GET or POST request from an Android app then you’ll want to get back to hacking together some basic apps. Pretty much every app I can think of makes REST requests, and this knowledge is fundamental. Android’s &lt;a href="https://developer.android.com/training/volley/simple.html" rel="noopener noreferrer"&gt;Volley&lt;/a&gt; class is a good place to start if you want to learn the absolute basics, but in an ideal world you’ll know that it’s a pretty outdated way of doing things.&lt;/p&gt;

&lt;p&gt;As such, if you’ve used an alternative such as Retrofit then you’ll be in a good place. There are a handful of other possible ways to do networking on Android but almost all of them are pretty niche nowâ€Š–&lt;a href="https://square.github.io/retrofit/" rel="noopener noreferrer"&gt;â€ŠRetrofit&lt;/a&gt; is super simple, pairs nicely with the power and flexibility of &lt;a href="https://github.com/square/okhttp" rel="noopener noreferrer"&gt;OkHttp&lt;/a&gt; and is regularly updated with great features by the extraordinary team at Square.&lt;/p&gt;

&lt;p&gt;Alongside that, some knowledge of serialisation would be great. Experience of Gson, Jackson, Moshi or similar is a great sign, as nobody in 2017 should be plucking values manually out of JSON.&lt;/p&gt;

&lt;h2&gt;
  
  
  Android StudioÂ Skills
&lt;/h2&gt;

&lt;p&gt;Android Studio has come an awfully long way since the first alpha rolled out several years ago now, back in the dark days when everyone used Eclipse. Even as a Junior, I’d want to see some indication that you know the program pretty wellâ€Š–â€Šnavigating everywhere by hand is a bad sign and horribly unproductive, so I like to see people using shortcuts a lot. In fact one of my favourite interview questions is to ask a candidate's favourite shortcut, as there are so many that I regularly learn something new.&lt;/p&gt;

&lt;p&gt;To be clear, I’m not expecting you to be a ninja by any stretch. But knowing your tools to a reasonable level shows interest in the craft. Knowing a few of &lt;a href="https://gautam.io/work/android_studio_shortcuts/" rel="noopener noreferrer"&gt;these&lt;/a&gt; will make you dramatically more productive and make pair programming much less painful.&lt;br&gt;
If you’re still using IntelliJ that’s fine too, and if you’re using Eclipse… well, I think I’d be more curious as to why than anything else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Git
&lt;/h2&gt;

&lt;p&gt;Another important one. Amazingly there are people these days who work without using a VCS system, and that’s a really big red flag for me. If you’re not using git right now you should be, and whilst the learning curve is a little steep the payoff is huge. Admittedly it can be difficult to see the benefit if you’ve solely worked by yourself up to this pointâ€Š–â€Šuntil you’ve realised that you’ve made a horrible error 6 hours into refactoring and want to revert to how the app was when it worked. &lt;a href="https://rogerdudler.github.io/git-guide/" rel="noopener noreferrer"&gt;This guide&lt;/a&gt; is no-nonsense and will get you started, and to be honest you don’t need any more than that.&lt;/p&gt;

&lt;p&gt;Even if you just use git from a GUI like the excellent &lt;a href="https://www.sourcetreeapp.com/" rel="noopener noreferrer"&gt;SourceTree&lt;/a&gt;, that’s fine with me.&lt;/p&gt;

&lt;p&gt;Of course there are a handful of other VCS systems out there and knowing any of them is greatâ€Š–â€Šbut git is the most widely used by far.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design Patterns
&lt;/h2&gt;

&lt;p&gt;This one is perhaps less essential, and I’m sure many use some of the more common patterns without realising that they’re classified as â€˜design patterns’. But if you know the basics such as Builders, Singletons and Factory Methods and where you might use them (or even where you can find an example in the Android SDK), then that’s great.&lt;/p&gt;

&lt;p&gt;If you happen to own or even just know about The Gang of Four or Effective Java, bonus points for you. Talking of which:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus Points
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You’ve ever written a Unit test, or understand why writing them on Android can be so amazingly difficult&lt;/li&gt;
&lt;li&gt;You own at least one of the all-time classic development books&lt;/li&gt;
&lt;li&gt;You’ve dabbled with other languages, Kotlin in particular&lt;/li&gt;
&lt;li&gt;You’ve published something to the Play Store&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Other Stuff
&lt;/h1&gt;

&lt;p&gt;Of course there are other attributes that I really like to see in someone applying for a Junior Developer role, which can mostly be filed under â€˜soft skills’.&lt;br&gt;
In my opinion, the role of a Junior is mostly to learn as much as they can as quickly as possible so that they can contribute meaningfully to the product. By and large, Juniors are assigned initially simple work by a Senior that will gradually take them deeper and deeper into the stack, building the developers confidence and skills along the way.&lt;/p&gt;

&lt;p&gt;As such, to be a good Junior I think it’s critical to have good autodidact skills, and to an extent you can prove that with what I would call peripheral knowledge. You might not know how to use it, but you know that RxJava is so hot right now and it’s been on your TODO list for some other time. A lot of blogs talk about Kotlin, so that’s on there too. You’ve heard about the awful world where we had to maintain compatibility with Gingerbread. You have some idea of what the next version of Android is bringing to the table. That sort of thing.&lt;/p&gt;

&lt;p&gt;Anything that shows that you’ve read around a bit is a really great sign, even if you’re only aware of some libraries/techniques/common issues/features.&lt;br&gt;
To that end, I’d hope that you’re signed up to the excellent &lt;a href="http://androidweekly.net/" rel="noopener noreferrer"&gt;Android Weekly&lt;/a&gt;, browse &lt;a href="https://www.reddit.com/r/androiddev/" rel="noopener noreferrer"&gt;/r/androiddev&lt;/a&gt;, and can maybe name a couple of the most influential people in the industry and follow their blogs, Mediums, &lt;a href="https://techbeacon.com/40-leading-android-developers-follow-twitter" rel="noopener noreferrer"&gt;Twitter accounts&lt;/a&gt; etc. Maybe you listen to &lt;a href="http://fragmentedpodcast.com/" rel="noopener noreferrer"&gt;Fragmented&lt;/a&gt; too.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F600%2F1%2AnG2imNZUOxLAieB89zBhvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F600%2F1%2AnG2imNZUOxLAieB89zBhvg.png" alt="android-o"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ultimately what I want to see more than almost anything else is some passion for the platform. I’ve been tinkering with Android for 6 years now and developing for 4, and I still get excited when I see an update from the Android team. I wasn’t expecting the Android O preview until months after it was actually announced, and I immediately flashed the (rather unstable) alpha to my device because I just had to have a play and find out what was new.&lt;/p&gt;

&lt;p&gt;I love checking out new devices when they get announced, I race to get the latest updates from APKMirror, I’ve flashed countless custom ROMs and bricked a few devices over the years. I always watch I/O when it’s on, and one day I’ll finally make the pilgrimage to Mountain View. I own several Android t-shirts, which for an adult male is ridiculous. If you can relate to any of that; you’re my kind of developer.&lt;/p&gt;

&lt;p&gt;Android is the most rapidly adopted technology in history, and I’m excited to be involved in it. If that excites you and you can tick off the majority of the boxes I’ve listed here then I’d like to work with you, and I look forward to teaching you as much as I can about the platform that I love.&lt;/p&gt;

</description>
      <category>android</category>
      <category>career</category>
      <category>development</category>
      <category>junior</category>
    </item>
  </channel>
</rss>
