flutter just_audio_background 错误:任务 ':app:processDebugMainManifest' 执行失败

Kdo*_*don 0 android-manifest flutter just-audio

我尝试设置just_audio_background但出现了一堆错误(如屏幕截图所示),当我遵循 main/AndroidManifest.xml 的修订并且不确定为什么似乎完全按照插件概述的步骤进行操作时。

我收到的警告是:

警告

运行应用程序时出现的异常原因是:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> com.android.manifmerger.ManifestMerger2$MergeFailureException: Error parsing /Users/mac/Documents/flutter_projects/zense_timer_project/zense_timer/android/app/src/main/AndroidManifest.xml
Run Code Online (Sandbox Code Playgroud)

这是 AndroidManifest.xml


<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <application
        android:label="zense_timer"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name="com.ryanheise.audioservice.AudioServiceActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->

        <service android:name="com.ryanheise.audioservice.AudioService"
            android:foregroundServiceType="mediaPlayback"
            android:exported="true" tools:ignore="Instantiatable">
            <intent-filter>
                <action android:name="android.media.browse.MediaBrowserService" />
            </intent-filter>
        </service>

        <!-- ADD THIS "RECEIVER" element -->
        <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>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <!-- ADD THIS "SERVICE" element -->

    </application>
</manifest>

Run Code Online (Sandbox Code Playgroud)

我已经运行 flutter clean 并重新启动,但仍然无法修复这些错误。

请注意,可能相关的是,在我对 just_audio_background 进行修改之前,我的 AndroidManifest 确实有这些警告,但我的应用程序仍然可以正常编译,并且从我读到的内容可能与 IDE 中的错误有关。

Unresolved class '{applicationName}'
Unresolved class '{applicationName}'
Cannot resolve symbol '@style/NormalTheme'
Run Code Online (Sandbox Code Playgroud)

这是清单的屏幕截图(添加插件更改之前)

以及插件更改后的屏幕截图

小智 8

在您的 AndroidManifest 文件中,

改变这个

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
Run Code Online (Sandbox Code Playgroud)

对此

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
Run Code Online (Sandbox Code Playgroud)