So having used one of the default templates in android studio I added a couple of imports and hit the error "unresolved reference" on preference and android.
Unsure if it was a minSdk issue I bumped the minSdk to 25 in build.gradle and re-synced it, still the same issue.
Any ideas anyone ?
OK so I am sure I never used to have to add anything to build.gradle, guessing it was done automatically and somehow I have turned that feature off ?, but apparently I do now to solve this ...
So for anyone else stuck with this :
Want … import kotlinx.android.synthetic.main.fragment_button.*
Make sure you include id 'kotlin-android-extensions' in build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
Want … import androidx.preference.PreferenceManager.getDefaultSharedPreferences
Make sure you include “implementation 'androidx.preference:preference:1.1.1'” in build.gradle
dependencies {
implementation 'androidx.preference:preference:1.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
…
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With