Setup Kotlin for Android Studio

This is believing you already have Android Studio (version 2.2 +), and its Android SDK (version 24+) and Java SDK (at least 7+) installed in you system.

Step - 1) Setup the Kotlin Plugin in Android Studio.

        To use the Kotlin in Android Studio we have to first add plugin in to the Android Studio

Android Studio ? Select Preference ? Select Plugins ? Browse Repository ? type “Kotlin” in search box ? and just install it


This is only one thing you have to do once for Android Studio and you can use it.

Step - 2) Add Kotlin classpath to project Build.Gradle

        For gradle we have support of the Kotlin  so we have to add two classpath that display below.

buildscript {
    ext.kotlin_version = "1.1.1"
    ext.supportLibVersion = "25.3.0"
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"

        // NOTE: Do't add project Dependencies here
       
    }
}
Advantages Of Kotlin in Android Development

         
              Kotlin is a best suitable language for developing Android applications, bringing all of the advantages of a modern language to the Android Application Development. Kotlin have the many new features which doesn't in java and C/C++.

Kotlin Platform without introducing any new restrictions:


Compatibility:
                            Kotlin is fully compatible with JDK 6 and 6+, ensuring that Kotlin applications can run on older Android devices with no errors.The Kotlin functionality is fully supported in Android Studio and compatible with the Android build system.

Performance:
                           Kotlin application runs as fast as an equivalent Java one, it's have the very similar bytecode structure. Kotlin's support for inline functions, code using lambdas often runs even faster than the same code written in Java.

Interoperability:
                             Kotlin is 100% interoperable with Java, allowing to use all existing Android libraries in a Kotlin application.

This includes annotation processing, so databinding and Dagger work too.

Footprint:
                         Kotlin has a very compact runtime library, which can be further reduced through the use of ProGuard. In a real application, the Kotlin runtime adds only a few hundred methods and less than 100K to the size of the .apk file.

Compilation Time:
                         Kotlin supports efficient incremental compilation, so while there's some additional overhead for clean builds, incremental builds are usually as fast or faster than with Java.

Learning Curve:
                             For a Java developer, getting started with Kotlin is very easy. The automated Java to Kotlin converter included in the Kotlin plugin helps with the first steps. Kotlin Koans offer a guide through the key features of the language
with a series of interactive exercises.


Android Development Tools


 Kotlin Android Extensions
          This is a compiler extension that allows you to get rid of findViewById() calls in your code and to replace them with synthetic compiler-generated properties.

      Anko
                                                  Is is a library providing set of  kotlin-friendly wrappers around the android Apis

Comments

Popular posts from this blog

Android QR Code Scanner using third party Library

Upload Image From Android Application To server

Kotlin Introduction