Google announces Android Pie SDK that is more “Kotlin-friendly”

Google’s Android Pie SDK is now more Kotlin-friendly

At Google’s I/O 2017 Developers Conference last year, the search giant had announced Kotlin would be an officially supported language in Android and it will join the list of existing programming languages used for Android app development, such as Java and C++. It is also predicted that Kotlin will be surpassing Java as the primary programming language used for Android apps by December 2018.

Moving further in this direction, Google who recently announced Android’s new operating system, Android 9.0 Pie has also released an SDK that is more Kotlin-friendly.

For those unaware, developed by JetBrains for JVM (Java Virtual Machine), Android, JS browser and native applications, Kotlin can be compiled to Java source code and can be used alongside Java to build apps. Like Java, Kotlin as a language is object-oriented and statically typed and fully interoperable with Java code. It is designed to solve the similar problem that Java does. It also adds a lot of nice-to-have features that Java itself doesn’t currently support, a much cleaner syntax, improved code readability, ideas from functional programming, and other improvements over Java. Also, Kotlin’s interoperability with Java makes it possible to call Kotlin code from Java or Java code from Kotlin.

Google in its new blog post announced that the newly released Android SDK contains nullability annotations for some of the most frequently used APIs, which will preserve the null-safety guarantee when your Kotlin code is calling into any annotated APIs in the SDK.

“Normally, nullability contract violations in Kotlin result in compilation errors. But to ensure the newly annotated APIs are compatible with your existing code, we are using an internal mechanism provided by the Kotlin compiler team to mark the APIs as recently annotated. Recently annotated APIs will result only in warnings instead of errors from the Kotlin compiler. You will need to use Kotlin 1.2.60 or later.

“Our plan is to have newly added nullability annotations produce warnings only, and increase the severity level to errors starting in the following year’s Android SDK. The goal is to provide you with sufficient time to update your code,” Google added.

If want to know how you can use the “Kotlin-friendly” SDK, simply follow the steps below.

1. Go to Tools > SDK Manager in Android Studio.

2. Choose Android SDon the left menu, and ensure that the SDK Platforms tab is open.

3. Check Android 8.+ (P) and click OK. This will install the Android SDK Platform 28 revision 6 if it is not already installed.

4. Then, set your project’s compile SDK version to API 28 to start using the new Android Pie SDK with nullability annotations.

Also, note that if your Kotlin plugin in Android Studio is not up-to-date, you will have to update it. Ensure that your Kotlin plugin version is 1.2.60 or later by going to Tools > Kotlin > Configure Kotlin Plugin Updates.

Once it’s set up, your builds will start showing warnings if you have any code that violates nullability contracts in the Android SDK. You will also start seeing warnings in Android Studio’s code editor if you call an Android API with the incorrect nullability.

For more information on the “Kotlin-friendly” SDK, you can click here.

Source: Android Developers Blog

Subscribe to our newsletter

To be updated with all the latest news

Kavita Iyer
Kavita Iyerhttps://www.techworm.net
An individual, optimist, homemaker, foodie, a die hard cricket fan and most importantly one who believes in Being Human!!!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe to our newsletter

To be updated with all the latest news

Read More

Suggested Post