Android NotificationCompat 无法解析为类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21055732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NotificationCompat cannot be resolved to a type
提问by Sauron
I am newer to Android and receive the error message: "NotificationCompat cannot be resolved to a type"
我是 Android 新手并收到错误消息:“NotificationCompat 无法解析为类型”
MinSDK=9, TargetSDK=18,
最小SDK=9,目标SDK=18,
As of yet, all sources are very vague on how to resolve this issue and simply note: "update the JAR files".
到目前为止,所有消息来源都对如何解决此问题非常含糊,并简单地注明:“更新 JAR 文件”。
What JARs do I need and where can I find them, so that this issue is resolved?
我需要哪些 JAR,在哪里可以找到它们,以便解决此问题?
回答by Embattled Swag
You need the support library. Here are the instructions on how to download them: http://developer.android.com/tools/support-library/setup.html
您需要支持库。以下是有关如何下载它们的说明:http: //developer.android.com/tools/support-library/setup.html
I needed to add "android-support-v4.jar" to my project to use the ActionBar
.
我需要将“android-support-v4.jar”添加到我的项目中才能使用ActionBar
.
回答by Kevin Krumwiede
Sometimes Eclipse gets hung up on this class, and no amount of cleaning and rebuilding will make it recognize that you have, in fact, added the support library and imported the correct class. I don't know why it always happens with this particular class. But the solution is to close and restart Eclipse.
有时 Eclipse 会挂在这个类上,再多的清理和重建都不会让它认识到你实际上已经添加了支持库并导入了正确的类。我不知道为什么它总是发生在这个特定的类中。但解决方法是关闭并重新启动 Eclipse。
回答by J E Carter II
From the support link(which has been updated)
来自支持链接(已更新)
With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX
随着 Android 9.0(API 级别 28)的发布,有一个名为 AndroidX 的支持库的新版本
From the menu: Refactor > Migrate to AndroidX...
从菜单中:重构 > 迁移到 AndroidX...
You will be prompted to back up your project to a zip. After that, a Refactor Preview will be shown in the console area. You should see a button "Do Refactor".
系统将提示您将项目备份到 zip。之后,控制台区域将显示重构预览。您应该会看到一个按钮“Do Refactor”。
This will remove the error under the noted conditions. You may find some lines of code now report as deprecated after the refactor.
这将在上述条件下消除错误。您可能会发现一些代码行在重构后现在报告为已弃用。