繁体   English   中英

未解决的参考导入 kotlinx.android 和 androidx.preference?

[英]Unresolved reference importing kotlinx.android and androidx.preference?

因此,在 android 工作室中使用了默认模板之一后,我添加了几个导入并在首选项和 android 上点击错误“未解决的参考”。

不确定这是否是 minSdk 问题,我在 build.gradle 中将 minSdk 提高到 25 并重新同步,仍然是同样的问题。

有什么想法吗?

好的,所以我确定我以前从来不需要向 build.gradle 添加任何内容,猜测它是自动完成的,并且不知何故我已经关闭了该功能?但显然我现在要解决这个问题......

因此,对于其他坚持这一点的人:

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'
…

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM