Home > Blockchain >  android.synthetic library isn't being recognized in android studio
android.synthetic library isn't being recognized in android studio

Time:08-13

In my Activity.kt class, the synthetic isn't being recognized in the import

import kotlinx.android.synthetic...

I have included the following in my build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

When trying it import, it will recognize extensions and parcel

import kotlinx.android.extensions...
import kotlinx.android.parcel...

So why is synthetic the only one not being recognized?

Other info: I have tried invalidating caches and restarting. I have another computer that also has this android studio project (Same gradle versions and everything). Everything works fine there.

Edit:

  1. I understand the current way to do it is to use data binding. But this is just a project we need to sustain, not improve and upgrade. We have a custom sdk (added many years ago) in the project that is making it hard to upgrade gradle and modernize.
  2. The project, even though synthetic is not recognized, is building and uploading fine. I just want to remove these red lines of error.

Any advice on how to start trouble shooting would be greatly appreciated.

CodePudding user response:

Synthetics were deprecated and removed in the latest version of Android Studio (Chipmunk). The recommendation is to migrate to using view binding. If you cannot do that, then you'll need to use an older version of Android Studio.

Migrating to view binding from synthetics is generally straightforward, so that's the better long term solution of course, but changing the IDE version is a quick short term solution.

Even projects in maintenance mode require occasional maintenance - like dealing with deprecations.

  • Related