4

I want to use the features of kotlin @Parcelize, I have apply the plugin: 'kotlin-android-extensions' on gradle, and I added

androidExtensions { 
    experimental = true 
}

but errors continue to appear.this error message :

Error:(28, 0) Could not find method androidExtensions() for arguments [build_8di01fmxa4d18k9q0yy3fdd20$_run_closure2@27f46852] on project ':app' of type org.gradle.api.Project.
<a href="openFile:F:\BELAJAR\ANDROID\AndroidStudioProjects\KADE\app\build.gradle">Open File</a>
Morteza Jalambadani
  • 2,190
  • 6
  • 21
  • 35
salim
  • 95
  • 2
  • 5

4 Answers4

9
  • Use the latest version of Kotlin (>= v1.1.51)
  • Use the latest version of Kotlin Android Extensions in your app module, so your build.gradle may look like:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
   androidExtensions {
     experimental = true
   } 
}

dependencies {
  // ...
}
aSemy
  • 5,485
  • 2
  • 25
  • 51
SML
  • 2,172
  • 4
  • 30
  • 46
3

For Using of Kotlin parcelize you have to follow these steps:

1- Add this line into your Gradle:

apply plugin: 'org.jetbrains.kotlin.android.extensions'

2-Enable android Extensions in your Gradle too :

 androidExtensions {
        experimental = true
    }

That's it. But be aware that you have added apply plugin: 'kotlin-android-extensions' in your gradle too if you didn't before.

Ehsan
  • 2,676
  • 6
  • 29
  • 56
  • The plugin has since been updated to `'kotlin-android-extensions'` as mentioned by @SML, i.e. You no longer need following `apply plugin: 'org.jetbrains.kotlin.android.extensions'` – Akshay Sep 30 '19 at 22:32
0

Just add this line in build file classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

basavaraj ganagi
  • 61
  • 1
  • 2
  • 6
0
  1. Add these plugins up to step 2.

    • apply plugin: 'com.android.application'
    • apply plugin: 'kotlin-android'
    • apply plugin: 'kotlin-android-extensions'
android {
    androidExtensions {
        experimental = true
    }
}
rgettman
  • 176,041
  • 30
  • 275
  • 357
WojtRR
  • 1