【问题标题】:Cannot read packageName from ...\src\main\AndroidManifest.xml无法从 ...\src\main\AndroidManifest.xml 读取 packageName
【发布时间】:2018-11-06 17:39:47
【问题描述】:

当我尝试构建我的项目时,我在 Android Studio 中收到此错误: 无法从 ..\src\main\AndroidManifest.xml 读取 packageName

我之前将我的项目从 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 中的包不匹配,但不幸的是它们不适用在这种情况下。

以前有人遇到过这种情况吗?

【问题讨论】:

  • 创建一个新项目并复制类和包。最快的方法真的
  • 删除/app/build/build/.idea文件夹,然后重试。
  • 我听取了您的建议并创建了一个新项目并添加了所有类和 xml 文件,该项目现在正在运行。它创建的文件结构与从 Eclipse 迁移时不同。

标签: android android-studio


【解决方案1】:

从您的代码中我发现可能在您的样式资源 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>

也许对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-26
    • 1970-01-01
    • 2014-04-01
    • 1970-01-01
    相关资源
    最近更新 更多