无法解析符号 'FloatingActionButton'
cannot resolve symbol 'FloatingActionButton'
最近我从 GitHub 下载了一个代码并与我的 android 工作室同步。这样做时我遇到了很多错误和问题,并以某种方式修复了其中的大部分。但是,我现在遇到的最后一个问题是我的 android 工作室找不到 class FloatingActionButton,如您在此屏幕截图中所见
需要注意的是,之前许多其他 classes,包括 'AppCompatActivity' 无法解析。将依赖项更改为以下解决了问题
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
但即使在更改依赖项、清理构建项目、执行 'Invalidate Caches / Restart...' 之后,'FloatingActionButton' 的问题仍然存在。谁能帮我解决这个问题?
您可以检查存储库 here
这是发生错误的java code of the activity
AndroidX 更新:
@Sub 6 Resources 的回答在 androidX 被引入之前是完美的。现在,最好包含以下依赖项而不是接受的答案的依赖项:
com.google.android.material:material:1.0.0
注意:当您阅读本文时,它可能不是最新版本。
FloatingActionButton 在设计库中。
将此行添加到您的依赖项中:
implementation 'com.android.support:design:27.1.1'
这个post还有更多关于FloatingActionButton
的一般信息:
@Sub 6 Resources 已经完全回答了这个问题,但我想添加一个额外的提示。如果您已将 implementation 'com.android.support:design:27.1.1'
添加到您的代码中,但编译器仍无法解析 FloatingActionButton class,只需 重建您的项目 。我和一位同事最近遇到了同样的问题,而依赖项已经存在,一个简单的重建就解决了所有问题。
希望对您有所帮助.. 编码愉快!
最近我从 GitHub 下载了一个代码并与我的 android 工作室同步。这样做时我遇到了很多错误和问题,并以某种方式修复了其中的大部分。但是,我现在遇到的最后一个问题是我的 android 工作室找不到 class FloatingActionButton,如您在此屏幕截图中所见
需要注意的是,之前许多其他 classes,包括 'AppCompatActivity' 无法解析。将依赖项更改为以下解决了问题
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
但即使在更改依赖项、清理构建项目、执行 'Invalidate Caches / Restart...' 之后,'FloatingActionButton' 的问题仍然存在。谁能帮我解决这个问题?
您可以检查存储库 here
这是发生错误的java code of the activity
AndroidX 更新:
@Sub 6 Resources 的回答在 androidX 被引入之前是完美的。现在,最好包含以下依赖项而不是接受的答案的依赖项:
com.google.android.material:material:1.0.0
注意:当您阅读本文时,它可能不是最新版本。
FloatingActionButton 在设计库中。
将此行添加到您的依赖项中:
implementation 'com.android.support:design:27.1.1'
这个post还有更多关于FloatingActionButton
的一般信息:
@Sub 6 Resources 已经完全回答了这个问题,但我想添加一个额外的提示。如果您已将 implementation 'com.android.support:design:27.1.1'
添加到您的代码中,但编译器仍无法解析 FloatingActionButton class,只需 重建您的项目 。我和一位同事最近遇到了同样的问题,而依赖项已经存在,一个简单的重建就解决了所有问题。
希望对您有所帮助.. 编码愉快!