草庐IT

java - "ic_launcher cannot be resolved or is not a field"

coder 2023-11-29 原文

我正在学习 Android 的教程并且 完成所有操作后,我在这段代码中遇到了问题:

getDrawable(R.drawable.ic_launcher);

我收到消息了

**"ic_launcher cannot be resolved or is not a field"**

此外,我的图标没有出现在平板电脑模拟器中, 但自动启动。 怎么回事?

最佳答案

将“mipmap”替换为“drawable”

我在学习教程时遇到了同样的问题,我发现我的 AndroidManifest.xml 文件具有以下代码:-

android:icon="@mipmap/ic_launcher

所以我将 R.drawable 更改为 R.mipmap 它解决了问题。无论我在哪里找到 drawable,我都会用 mipmap 替换它。很高兴用 android studio 1.1 检查 mipmap。 了解更多信息:- https://androidbycode.wordpress.com/2015/02/14/goodbye-launcher-drawables-hello-mipmaps/

关于java - "ic_launcher cannot be resolved or is not a field",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19385467/

有关java - "ic_launcher cannot be resolved or is not a field"的更多相关文章

随机推荐