android - XML解析错误(Android Studio)在哪里?

标签 android gradle

关闭。这个问题需要details or clarity .它目前不接受答案。












想改进这个问题?通过 editing this post 添加详细信息并澄清问题.

2年前关闭。




Improve this question




这个错误已经发生过几次,而且大多数时候它只是随着更新而消失。
当我尝试运行我的小应用程序时,Android Studio 说:
错误:无法解析 C:\Users...\AndroidStudioProjects\Getraenkerechner\app\src\main\AndroidManifest.xml 中的 XML
[row,col] 处的 ParseError:[14,16]
消息:预期的开始或结束标记
受影响的模块:app

这是 AndroidManifest 的内容:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".Support"
        android:screenOrientation="portrait">
        ></activity>
    <activity android:name=".WaterCalc"
        android:screenOrientation="portrait">
        ></activity>
    <activity
        android:name=".MainActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <meta-data
        android:name="preloaded_fonts"
        android:resource="@array/preloaded_fonts" />
</application>

知道问题可能是什么吗?
我尝试安装新的 gradle 版本,但没有帮助..

提前致谢...

最佳答案

我认为您缺少 manifest标签。当然不要忘记更改包名。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp"
    android:versionCode="1"
    android:versionName="1.0" >
    <!-- put here the code you posted -->
</manifest>

要了解有关 Manifest 文件的更多信息,请阅读 doc .

在您的情况下,正确的 list 格式将是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp"
    android:versionCode="1"
    android:versionName="1.0" >
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name=".Support"
            android:screenOrientation="portrait">
        </activity>

        <activity android:name=".WaterCalc"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".MainActivity"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="preloaded_fonts"
            android:resource="@array/preloaded_fonts" />
    </application>
</manifest>

关于android - XML解析错误(Android Studio)在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59619473/

相关文章:

Android:相当于IOS的 "applicationDidEnterBackground()"

android - 在 Android 中频繁保存首选项有什么缺点吗?

android - 创建使用 AAR 文件作为依赖项的 Android 库

android - 在多模块 Android 项目中导入库的最佳实践

java - LibGDX:平铺 map 的视差效果

javascript - 安卓浏览器 : fill vertical viewport?

android - 将 float 操作按钮集成到带有工具栏的线性布局中

java - 如何在特定条件下停止 Gradle 或 Maven 构建

java - Checkstyle 找不到抑制.xml

android - PackageParserException : Package . ..base.apk 在条目 AndroidManifest.xml 中没有证书