Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable kotlin-android-extensions deprecation warning

My project's migration to View Binding is underway but in the meantime this warning is distracting when looking at build logs

Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.

How can I disable it?

like image 725
kassim Avatar asked Dec 07 '20 16:12

kassim


People also ask

Is kotlin synthetic deprecated?

Kotlin Android Extensions is deprecated, which means that using Kotlin synthetics for view binding is no longer supported.

Is Parcelize deprecated?

As the @Parcelize functionality is extracted (KT-42120), the rest of the Android Extensions functionality can be deprecated in favour of View Binding. The existing Android Extensions plugin will continue to work, however, a warning message will be shown.

What is kotlin Android extensions?

The Kotlin Android Extensions is a compiler plugin that allows you to access views from your XML directly in activities, fragments and views using what they refer to as synthetic properties. To use it, ensure that the plugin is enabled in your module's build.gradle file: apply plugin: 'kotlin-android-extensions'


2 Answers

I also recently faced this problem and found out.

In Kotlin 1.4.20-M2, JetBrains deprecated the Kotlin Android Extensions compiler plugin in favor of View Binding, and Also, Google is promoting modularisation, but synthetic properties don’t work cross-module.

So to fix this warning. Remove apply plugin: 'kotlin-android-extensions' in your build.gradle file

Note: If you're using Parcelize.

Don’t forget that the Parcelize feature in Kotlin is part of the kotlin-android-extensions compiler plugin, so removing the plugin will end up making all your Parcelable classes not compiling if they depend on the Parcelize annotation.

JetBrains extracted the Parcelize from Kotlin Android Extensions to a new plugin, kotlin-parcelize

First, you will need to add kotlin-parcelize plugin to your project build.gradle file.

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

Then change your old import statement from

import kotlinx.android.parcel.Parcelize

to

import kotlinx.parcelize.Parcelize

For more info, I recommend you to read this Blog Migrating the deprecated Kotlin Android Extensions compiler plugin

like image 138
Muhammad Farhan Avatar answered Sep 26 '22 23:09

Muhammad Farhan


Just you need to remove this line from your Gradle:

apply plugin: 'kotlin-android-extensions'
like image 35
Mohammad Mirzakhani Avatar answered Sep 22 '22 23:09

Mohammad Mirzakhani