flutter just_audio_background 错误:执行任务“:app:processDebugMainManifest”失败。

huangapple go评论77阅读模式
英文:

flutter just_audio_background error: Execution failed for task ':app:processDebugMainManifest'

问题

我试图设置just_audio_background,但遇到了一堆错误(如屏幕截图所示),当我按照主/AndroidManifest.xml的修改步骤操作时,我不确定为什么,因为看起来完全按照插件的步骤来进行。

我收到的警告是:

flutter just_audio_background 错误:执行任务“:app:processDebugMainManifest”失败。

当我运行应用程序时,我收到的异常原因是:

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

以下是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>

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

请注意,可能与此相关的是,我的AndroidManifest在我进行just_audio_background的修改之前确实出现了这些警告,但是我的应用程序仍然能够编译,从我所读的内容来看,这可能与IDE中的错误相关。

flutter just_audio_background 错误:执行任务“:app:processDebugMainManifest”失败。

flutter just_audio_background 错误:执行任务“:app:processDebugMainManifest”失败。

英文:

Am trying to set up just_audio_background but get a bunch of errors (as per screenshot), when I follow the amendments to the main/AndroidManifest.xml and not sure why as appears to follow the steps exactly as the plugin outlines.

The warnings I get are:

flutter just_audio_background 错误:执行任务“:app:processDebugMainManifest”失败。

And the exception reason I get when I run the app is:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task &#39;:app:processDebugMainManifest&#39;.
&gt; com.android.manifmerger.ManifestMerger2$MergeFailureException: Error parsing /Users/mac/Documents/flutter_projects/zense_timer_project/zense_timer/android/app/src/main/AndroidManifest.xml

And here is the AndroidManifest.xml


&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
&lt;uses-permission android:name=&quot;android.permission.WAKE_LOCK&quot;/&gt;
&lt;uses-permission android:name=&quot;android.permission.FOREGROUND_SERVICE&quot;/&gt;
&lt;application
android:label=&quot;zense_timer&quot;
android:name=&quot;${applicationName}&quot;
android:icon=&quot;@mipmap/ic_launcher&quot;&gt;
&lt;activity
android:name=&quot;com.ryanheise.audioservice.AudioServiceActivity&quot;
android:exported=&quot;true&quot;
android:launchMode=&quot;singleTop&quot;
android:theme=&quot;@style/LaunchTheme&quot;
android:configChanges=&quot;orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode&quot;
android:hardwareAccelerated=&quot;true&quot;
android:windowSoftInputMode=&quot;adjustResize&quot;&gt;
&lt;!-- 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. --&gt;
&lt;meta-data
android:name=&quot;io.flutter.embedding.android.NormalTheme&quot;
android:resource=&quot;@style/NormalTheme&quot;
/&gt;
&lt;intent-filter&gt;
&lt;action android:name=&quot;android.intent.action.MAIN&quot;/&gt;
&lt;category android:name=&quot;android.intent.category.LAUNCHER&quot;/&gt;
&lt;/intent-filter&gt;
&lt;/activity&gt;
&lt;!-- Don&#39;t delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --&gt;
&lt;service android:name=&quot;com.ryanheise.audioservice.AudioService&quot;
android:foregroundServiceType=&quot;mediaPlayback&quot;
android:exported=&quot;true&quot; tools:ignore=&quot;Instantiatable&quot;&gt;
&lt;intent-filter&gt;
&lt;action android:name=&quot;android.media.browse.MediaBrowserService&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/service&gt;
&lt;!-- ADD THIS &quot;RECEIVER&quot; element --&gt;
&lt;receiver android:name=&quot;com.ryanheise.audioservice.MediaButtonReceiver&quot;
android:exported=&quot;true&quot; tools:ignore=&quot;Instantiatable&quot;&gt;
&lt;intent-filter&gt;
&lt;action android:name=&quot;android.intent.action.MEDIA_BUTTON&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/receiver&gt;
&lt;meta-data
android:name=&quot;flutterEmbedding&quot;
android:value=&quot;2&quot; /&gt;
&lt;!-- ADD THIS &quot;SERVICE&quot; element --&gt;
&lt;/application&gt;
&lt;/manifest&gt;

I have run flutter clean and restarted but still can't fix these errrors.

Note possibly related, my AndroidManifest does have these warnings before I make amendments for just_audio_background, but my app still compiles fine and from what I read might be related to a bug in the IDE.

Unresolved class &#39;{applicationName}&#39;
Unresolved class &#39;{applicationName}&#39;
Cannot resolve symbol &#39;@style/NormalTheme&#39;

flutter just_audio_background 错误:执行任务“:app:processDebugMainManifest”失败。

flutter just_audio_background 错误:执行任务“:app:processDebugMainManifest”失败。

答案1

得分: 3

在你的 AndroidManifest 文件中,

将这部分修改为

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
英文:

In your AndroidManifest file,

Change this:

&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;

To this:

&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;

huangapple
  • 本文由 发表于 2023年6月2日 13:04:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76387262.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定