Plugin 'kotlin-parcelize' not found

Viewed 18614

Google is recommending users to migrate from kotlin-android-extensions to kotlin-parcelize.

However, Gradle sync fails with the following error:

Plugin [id: 'kotlin-parcelize'] was not found in any of the following sources:

- Gradle Core Plugins (not a core plugin, please see https://docs.gradle.org/6.1.1/userguide/standard_plugins.html for available core plugins)
- Plugin Repositories (plugin dependency must include a version number for this source)

Where is the plugin located?

8 Answers

kotlin-parcelize ships with Kotlin Plugin 1.4.20
(Release Announcement: Deprecation of Kotlin Android Extensions)

You need to upgrade your Kotlin versions and run Gradle sync again.

dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20"
}

1, update your AndroidStudio kotlin version
From menu, select Tools -> Kotlin -> Configure Kotlin Plugin Updates -> choose a kotlin version -> install -> and restart AS

2, update your dependencies classpath with the new kotlin version then sync project (like Brown Smith answer)

3
builld.gradle (:app)

plugins {
    ...
    id 'kotlin-parcelize'
}

MyObject.kt

import kotlinx.parcelize.Parcelize

@Parcelize
class MyObject(val name: String, val age: Int) : Parcelable {

}

This is the latest september 2021 implementation :

If you're using 'org.jetbrains.kotlin.android' version '1.5.20' or above , and you fail to find the parcelize tag , you can add it using the plugins DSL in the settings.gradle :

plugins {  
 id "org.jetbrains.kotlin.plugin.parcelize" version "1.6.0-M1" 
}

and then call it in your app build.gradle like this :

plugins { 
id 'org.jetbrains.kotlin.plugin.parcelize'
}

In your module level build.gradle file add,

plugins {
    ...
    id 'kotlin-parcelize'
}

In your project level build.gradle file add,

buildscript {
    ...
    repositories {
        google()
        jcenter()
    }
dependencies {
    ...
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32"
    
    }
}

Here '1.4.32' is the Kotlin package version. You will now be able to find the Parcelize package. Also while importing make sure to import,

'import kotlinx.parcelize.Parcelize' package.

Try this

in bulid.gradle (Project:*appname*) add:

buildscript {
    
    dependencies {
        ...
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
    }
}

and in bulid.gradle (Module:*appname*) add:

plugins {
    ...
    id 'org.jetbrains.kotlin.plugin.parcelize'
} 

If it didn't work for you check this link (if there's a new update): https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.parcelize

1. Make sure Gradle should be on Online mode

enter image description here

2. apply plugin: 'kotlin-parcelize'

3. need to upgrade your Kotlin versions 1.4.20 or above and run Gradle sync again.

dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
}

in newest android studio in Nov 2021:

in setting.gradle add this line:

id("org.jetbrains.kotlin.plugin.parcelize") version "1.6.0-M1"

and in build.gradle of module:

 id("org.jetbrains.kotlin.plugin.parcelize")

Add this to your app level build.gradle file

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
Related