android - 无法从 ...\src\main\AndroidManifest.xml 读取 packageName
问题描述
当我尝试构建我的项目时,我在 Android Studio 中收到此错误:无法从 .. 读取 packageName\src\main\AndroidManifest.xml
我之前将我的项目从 Eclipse 迁移到 Android Studio 并且 AndroidManifest.xml 文件不在上面的目录中,它位于:..\app\src\main\AndroidManifest.xml
当我创建 ..\src\main
目录并将AndroidManifest.xml
文件复制到其中时,我得到一个新错误列表,见下文。我是否必须创建该目录,或者这是导致新错误的原因?:
..\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:46: error: resource style/MyTheme (aka style/MyTheme) not found.
..\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:57: error: resource string/app_name (aka string/app_name) not found.
..\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:68: error: resource string/app_name (aka string/app_name) not found.
我已经阅读了与此类似的先前问题的答案,主要指向格式不佳的 xml 的问题,或者 build.gradle 中的 applicationId 与 AndroidManifest.xml 中的包不匹配,但不幸的是它们不适用于这种情况.
有没有人遇到过这个?
解决方案
从您的代码中,我发现可能在您的样式资源 appTheme 中未定义。所以首先将此代码放入您的 style.xml 文件中。
<!-- Base application theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
注意:您还需要在资源文件中定义颜色。
然后将此代码添加到您的资源文件中
<string name="app_name">your app name</string>
也许它会帮助你。
推荐阅读
- oauth - 在 Microsoft BotFramework-Composer 中使用 oauth 时出现“对象引用未设置为对象的实例”错误
- sql - Presto 默认日期显示不正确
- python - python +升级密码学pkg后没有名为cryptography.fernet的模块
- python - StaleElementReferenceException:消息:元素引用已过时
- mysql - MySQL 查询 - 将结果集转换为 JSON
- javascript - 为嵌套模式 graphql/apollo/react 添加突变
- php - 当我在 CodeIgniter 中为数据表源选择多个数据时,我在 ORDER BY 中遇到问题,但出现 500 错误
- python - 在 Python 中使用正则表达式匹配小时:分钟时间格式
- api - 获取 GoToWebinar 注册人
- angular - Angular Material:我在单击按钮时以 Angular 形式再添加一行 matInput。但 matInput 提交的 UI 未正确加载