android - 必须声明清单元素
问题描述
此错误发生在位于 mipmap-anydpi-v26 目录中的 ic_launcher.xml 文件中,即使我尝试更改其位置也无法解决。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.robpercival.listviewdemo">
<application android:allowBackup="true"
android:icon="@mipmap/ic_launcher"/>
</manifest >
RelativeLayout 和菜单元素也会出现类似的问题,我通过从可绘制目录中删除 ic_launcher 文件并在菜单和布局目录中创建新文件来解决这些问题。我不确定,但是当 android studio 版本更新到 3.5 时,可能会出现这些问题。
解决方案
问题是您从可绘制文件夹中删除“ic_launcher”文件以解决RelativeLayout 菜单元素问题,
但是这个文件链接在 mipmap 文件夹中/mipmap/ic_launcher/ic_launcher.xml
。/mipmap/ic_launcher_round/ic_launcher_round.xml
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
只需删除2个文件
/mipmap/ic_launcher/ic_launcher.xml(anydpi-26)
/mipmap/ic_launcher_round/ic_launcher_round.xml(anydpi-26)
编辑
或者,
将 ic_launcher_round(xxxhdpi) 复制到可绘制文件夹。
并编辑
/mipmap/ic_launcher/ic_launcher.xml(anydpi-26)
/mipmap/ic_launcher_round/ic_launcher_round.xml(anydpi-26)
像这样
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_round" />
<foreground android:drawable="@drawable/ic_launcher_round" />
</adaptive-icon>
推荐阅读
- html - 将电子邮件另存为 PDF
- javascript - 对话框关闭时删除事件的问题(React useEffect)
- javascript - 递归不返回正确的结果
- python - 以特定的 json 格式保存 csv
- asp.net-mvc - 有没有办法区分特定的 System.Web.HttpException?
- r - 可视化对话中的眨眼
- swagger - springdoc / Swagger UI 未将 OAuth2 令牌传递给 API
- python - 使用 Pandas 读取 sql 查询的 Postgres 连接器类
- asp.net-core - 如何在 Blazor WebAssembly 中直接从服务器加载图像/视频?
- xamarin.forms - 当xamarin中的应用程序启动时间形成MVVM时如何创建视图模型实例