What is kapt?

kapt is short for Kotlin annotation processor tool.

Why do I need it?

tl;dr; every time you use an annotation in a Kotlin file you need to use kapt.

Prerequisites

dependencies {
    kapt("groupId:artifactId:version")
}
plugins {
    kotlin("kapt") version "1.5.31"
}

Further reading

https://kotlinlang.org/docs/kapt.html

What is Ninja?

Ninja is a build system which replaces the GNU make in AOSP

  • Up to Marshmallow / 6,0 the build system was based on GNU Make
  • In Nougat / 7.0 and later, the build is run by ninja
  • Ninja works from a pre-processed manifest generated by kati and soong

kati

kati converts Android.mk files into ninja manifests

soong

soong converts blueprint files (Android.bp) into ninja manifests

Example bp file

https://android.googlesource.com/platform/system/core/+/refs/tags/android-11.0.0_r46/logcat/Android.bp

Further reading

https://ninja-build.org/

How can you use StrictMode in your Android app?

import android.os.StrictMode
import android.os.StrictMode.ThreadPolicy
import android.os.StrictMode.VmPolicy


class LevelUpApplication : Application() {
    override fun onCreate() {
        if (BuildConfig.DEBUG) {
            StrictMode.setThreadPolicy(
                ThreadPolicy.Builder()
                    .detectDiskReads()
                    .detectDiskWrites()
                    .detectNetwork()
                    .penaltyLog()
                    .build()
            )
            StrictMode.setVmPolicy(
                VmPolicy.Builder()
                    .detectLeakedSqlLiteObjects()
                    .detectLeakedClosableObjects()
                    .penaltyLog()
                    .penaltyDeath()
                    .build()
            )
        }
        super.onCreate()

https://developer.android.com/reference/android/os/StrictMode

The Boy Scout Rule

Always leave the campground cleaner than you found it.

Boy Scout rule in Clean Code


Always leave the code you are editing a little
bit better than you found it