【问题标题】:How to solve ERROR: Failed to parse XML in AndroidManifest.xml in Flutter如何解决 ERROR: Failed to parse XML in AndroidManifest.xml in Flutter
【发布时间】:2020-06-10 13:44:48
【问题描述】:

我尝试了几种方法,例如删除标签、添加标签等,但我的 AndroidManifest.xml 文件中仍然出现此错误

错误:无法解析 E:\flutter_Apps\flutter_app_dont_stare_v2\android\app\src\main\AndroidManifest.xml 中的 XML [row,col] 处的 ParseError:[23,35] 消息:预期的开始或结束标记 受影响的模块:app

Image of error

>>>>>>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.flutterappdontstarev2"
    tools:ignore="ExtraText">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.SET_ALARM" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <application tools:ignore="ExtraText">
        android:name=".Application"
        android:label="Stare Away"
        android:icon="@mipmap/ic_launcher"

        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="wxxxxxxxxxxxxxxxxxxx1" />

        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />

        <service
            android:name="io.flutter.plugins.androidalarmmanager.AlarmService"
            android:exported="false"
            android:permission="android.permission.BIND_JOB_SERVICE" />

        <receiver
            android:name="io.flutter.plugins.androidalarmmanager.AlarmBroadcastReceiver"
            android:exported="false" />
        <receiver
            android:name="io.flutter.plugins.androidalarmmanager.RebootBroadcastReceiver"
            android:enabled="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
            </intent-filter>
        </receiver>
        <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
            </intent-filter>
        </receiver>
        <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />


    </application>
</manifest>

【问题讨论】:

  • 发布您的AndroidManifest.xml 代码

标签: flutter dart


【解决方案1】:

删除第 20 行末尾的 &gt;。 还将第 25 行末尾的 /&gt; 更改为 &gt;

所以 Xml 可以是有效的

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.flutterappdontstarev2"
    tools:ignore="ExtraText">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.SET_ALARM"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.VIBRATE"/>

    <application
        tools:ignore="ExtraText"
        android:name=".Application"
        android:label="Stare Away"
        android:icon="@mipmap/ic_launcher">

        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"


        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />

        <service
            android:name="io.flutter.plugins.androidalarmmanager.AlarmService"
            android:exported="false"
            android:permission="android.permission.BIND_JOB_SERVICE" />

        <receiver
            android:name="io.flutter.plugins.androidalarmmanager.AlarmBroadcastReceiver"
            android:exported="false" />
        <receiver
            android:name="io.flutter.plugins.androidalarmmanager.RebootBroadcastReceiver"
            android:enabled="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
            </intent-filter>
        </receiver>
        <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
            </intent-filter>
        </receiver>
        <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
    </application>
</manifest>

【讨论】:

  • @JideGuru 我已将其包含在编辑中。感谢您的帮助
猜你喜欢
  • 1970-01-01
  • 2021-10-15
  • 1970-01-01
  • 2023-04-09
  • 2021-12-03
  • 2017-08-02
  • 2022-12-02
  • 2021-08-05
  • 2022-12-03
相关资源
最近更新 更多