Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Enable Kotlin Android Extensions by Default in Android Studio 4.1

Why kotlin-android-extensions not enabled by default in this latest version of Android Studio? In fact, as long as i know, i have to manually add the plugin in gradle files. Any workaround so that i can add the plugin and enable it automatically everytime i create new project? Thanks before.

ICYMI, this is the code that needs to be added to enable kotlin-android

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    // add kotlin-android-extensions
    id 'kotlin-android-extensions'
}
like image 269
wiryadev Avatar asked Oct 19 '20 16:10

wiryadev


People also ask

Why is Kotlin Android extension gradle plugin deprecated?

They are not supported with Java. There are still projects that are written in Java and may not be fully migrated to Kotlin yet, and hence Kotlin Synthetics may not be a consistent way of getting the ViewIds in your project. Because of these issues, Kotlin Synthetics is now being deprecated.


2 Answers

kotlin-android-extensions is deprecated, you must use view binding

like image 132
mouss2388 Avatar answered Sep 20 '22 18:09

mouss2388


In Kotlin 1.4.20-M2 JetBrains deprecated Kotlin Android Extensions compiler plugin.

kotlinx.android.synthetic is no longer a recommended practice. Removing in favour of explicit findViewById

Very sad news :(, i hate viewBinding

like image 22
Gaston Fassi Lavalle Avatar answered Sep 22 '22 18:09

Gaston Fassi Lavalle