解析 LocalFile 时出错:'...\AndroidManifest.xml' 请确保 Android 清单是有效的 XML 文档,然后重试

问题描述 投票:0回答:2

我的manifest.xml 出了点问题。我不知道那是什么。我很快就会为此疯狂。我升级了 kotlin 和 gradle 版本,但遇到了一堆问题。 我一直在查看清单,但找不到错误。我也一直在 Stack Overflow 上查看所有问题和答案。我也是安卓新手。 我使用的框架是 Flutter。

         <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.digital.abcde">

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="32" />

    <uses-permission android:name="android.permission.INTERNET"/>
    <!-- ADD THESE TWO PERMISSIONS -->
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

   <application
       android:label="abcde"
       android:icon="@mipmap/ic_launcher"
       android:fullBackupContent="true"
       android:allowBackup="true">
        <activity
            android:name="com.ryanheise.audioservice.AudioServiceActivity"
            android:exported="true"
            tools:ignore="Instantiatable"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|
             smallestScreenSize|locale|layoutDirection
            |fontScale|screenLayout|density|uiMode"
            android:windowSoftInputMode="adjustResize">
      
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />

            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>

                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>

            </intent-filter>
        </activity>
    <!-- ADD THIS "SERVICE" element -->
    <service android:name="com.ryanheise.audioservice.AudioService"
        android:exported="false" tools:ignore="Instantiatable"
        android:screenOrientation="portrait"android:allowBackup="true">
        <intent-filter>
            <action android:name="android.media.browse.MediaBrowserService" />
        </intent-filter>
    </service>

    <receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver"
        android:exported="true"
        tools:ignore="Instantiatable">
        <intent-filter>
            <action android:name="android.intent.action.MEDIA_BUTTON" />
        </intent-filter>
    </receiver>

    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

我收到的错误消息是:

Error parsing LocalFile: 'C:\pro\projects\krimofonen\android\app\src\main\AndroidManifest.xml' Please ensure that the android manifest is a valid XML document and try again.

android android-manifest
2个回答
1
投票

由于某种原因缺少 xml 标头。你是不是忘记把它粘贴在这里了?如果确实丢失,请将其添加到清单文件的开头。

<?xml version="1.0" encoding="utf-8"?>

1
投票

您的

AndroidManifest.xml
的开头包含空格:

         <?xml version="1.0" encoding="utf-8"?>

确保

<
是文件中的第一个字符,这样就可以修复错误。

© www.soinside.com 2019 - 2024. All rights reserved.