Posts

Showing posts from July, 2017

How to use Android Frameworks Using Annotation Processing?

Image
Annotation Processing: Android Frameworks This tutorial describes how to use in Kotlin popular Android frameworks and libraries that rely on annotation processing.  The Android world has many popular frameworks simplifying development. You can use the same frameworks if you develop in Kotlin, often as easily as you'd do that in Java. This tutorial provides examples and highlights the differences in settings. We'll look at  Dagger ,  Butterknife ,  Data Binding ,  Auto-parcel  and  DBFlow  (other frameworks can be set up similarly). All these frameworks work through annotation processing: you annotate the code to have the boiler-plate code generated for you. Annotations allow to hide all the verbosity and keep your code simple, and if you need to understand what actually happens at runtime, you can look at the generated code. Note that all these frameworks generate source code in Java, not Kotlin. In Kotlin you specify the dependencies in a similar...

How to use Kotlin Android Extensions [Easy Guide]

Image
Kotlin Android Extensions This tutorial describes how to use Kotlin Android Extensions to improve support for Android development.  In this tutorial we'll walk through the steps required to use the Kotlin Android Extensions plugin, enhancing the development experience with Android. Background Every Android developer knows well the  findViewById()  function. It is, without a doubt, a source of potential bugs and nasty code which is hard to read and support. While there are several libraries available that provide solutions to this problem, being libraries dependent on runtime, they require annotating fields for each  View . The Kotlin Android Extensions plugin allows us to obtain the same experience we have with some of these libraries, without having to add any extra code or shipping any additional runtime. In essence, this would allow for the following code: // Using R.layout.activity_main from the main source set import kotlinx . android . synthetic . main . activ...

Easy Kotlin Tutorials [Step By Step]

Image
Getting started with Android and Kotlin This tutorial walks us through creating a simple Kotlin application for Android using Android Studio.  Installing the Kotlin plugin The Kotlin plugin is bundled with Android Studio starting from  version 3.0 . If you use an earlier version, you'll need to install the Kotlin plugin. Go to  File | Settings | Plugins | Install JetBrains plugin…  and then search for and install  Kotlin . If you are looking at the "Welcome to Android Studio" screen, choose  Configure | Plugins | Install JetBrains plugin…  You'll need to restart the IDE after this completes. Creating a project It’s extremely easy to start using Kotlin for Android development. In this tutorial we’ll follow the warming up process with Android Studio. If using Intellij IDEA with Android, the process is almost the same. First let's create a new project. Choose  Start a new Android Studio project  or  File | New project . The following dialog...