Skip to content

Most visited

Recently visited

navigation

Kotlin with Android Studio Known Issues

This page describes current known issues and limitations when using Kotlin with Android Studio 3.0. For more general issues in Android Studio's stable release, see the other Known Issues page.

To report an issue not already included here, see how to report a bug.

Can't build project with Kotlin

Error:Unable to find method 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List;'.

If you see this error, it's possible you have a pre-existing version of the Kotlin plugin that is incompatible with the new Android Plugin for Gradle that's in Android Studio 3.0. The solution is to delete the old Kotlin plugin.

Open your project-level build.gradle file and locate ext.kotlin_version. It should be 1.1.2-4 (or higher). If it shows an older version, you need to delete the old Kotlin plugin so it does not obstruct the version included with Android Studio 3.0. On Windows, it should be located at
C:\Users\user_name\AndroidStudio_version\config\plugins\Kotlin\.
On Mac, look in
~/Library/Application\ Support/AndroidStudio_version/Kotlin/.

Gradle sync error using Instant Apps SDK with Kotlin

Error:null cannot be cast to non-null type com.android.build.gradle.BasePlugin

The Instant Apps SDK is currently incompatible with the Kotlin plugin.

Compilation error in Login Activity template with Kotlin

Error:(89, 22) None of the following functions can be called with the arguments supplied:
@NonNull public open fun make(@NonNull view: View, @NonNull text: CharSequence, duration: Int): Snackbar defined in android.support.design.widget.Snackbar
@NonNull public open fun make(@NonNull view: View, @StringRes resId: Int, duration: Int): Snackbar defined in android.support.design.widget.Snackbar

The Login Activity template currently does not convert to Kotlin successfully. Line 89 contains an error because the mEmailView object is instantiated as AutoCompleteTextView, not a View. But this is easily fixed. You simply need to tell Kotlin to use the non-null value of View by adding two exclamation points:

Snackbar.make(mEmailView!!, R.string.permission_rationale, Snackbar.LENGTH_INDEFINITE)

Code doesn't compile after converting from Java file

In some situations, using Code > Convert Java File to Kotlin File results in Kotlin code that does not compile. This is a known issue with the Kotlin plugin.

Lint checks with Kotlin don't work from command line

Lint checks on Kotlin files only work from the Android Studio IDE. The currently do not run when you run lint directly from Gradle.

Code completion with Kotlin shows private resources

In Kotlin code completion, private resources are not filtered out the way they are from Java code completion. For example, typing R.drawable. lists a bunch of internal app compat resources as suggestions.

Live templates and postfix completion not fully available with Kotlin

When writing in Java language, you can use live templates or postfix completion, such as typing variable.for and presing Tab to generate a for-loop that iterates over the variable. However, these are not fully supported with Kotlin. And due to language difference, it's possible some never will be.

Some refactorings not available with Kotlin

Not all code refactorings works with Kotlin, especially those for Android. For example, code refactoring to modularize Kotlin cude currently does not work with Kotlin.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)