0

Something happend to my manifest.xml. I don't know what it is. I'm soon to be crazy about this. I uppgraded kotlin and gradle version, than I got a bunch of problems. I have been looking at the manifest and I can' find an error. I have been looking att all the quesion and answers here at Stack Overflow too. I'm also new to android. The framework I'm using is 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>

The error message I get is: 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.

Ryan M
  • 18,333
  • 31
  • 67
  • 74
PasPro
  • 55
  • 8
  • Tell the error messages you got. What happens? What do you see? – blackapps Feb 22 '22 at 14:13
  • typo? you forgot about space? – Selvin Feb 22 '22 at 14:28
  • error message is: 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. – PasPro Feb 22 '22 at 15:04
  • I edited the question with the error message. Could the error come from somewhere else in the project ? – PasPro Feb 22 '22 at 15:29
  • 1
    At the beginning of the file remove all white space before ` – Robert Feb 22 '22 at 18:21
  • [you don't need `` for xml 1.0](https://stackoverflow.com/questions/7007427/does-a-valid-xml-file-require-an-xml-declaration) - so the answers are wrong... problem is space or rather lack of it ... but SO is not "find typo in my code" service ... feel free to use xml validator to check where is the error – Selvin Mar 03 '22 at 15:04

2 Answers2

1

For some reason the xml header is missing. Did you just forget pasting it here? If it's really missing, add this to the beginning of your manifest file.

<?xml version="1.0" encoding="utf-8"?>
Yochyo
  • 72
  • 3
  • 5
1

The start of your AndroidManifest.xml contains whitespace:

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

Make sure that the < is the very first character in the file and that should fix the error.

Ryan M
  • 18,333
  • 31
  • 67
  • 74