Following the procedure to add the package just_audio_background and running flutter run --verbose on a physical device the procedure gets stuck at

[  +94 ms] Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x20000000
cmp=com.lirmusic.LIRMUSIC/com.ryanheise.audioservice.AudioServiceActivity (has extras) }

           Error type 3
           Error: Activity class {com.lirmusic.LIRMUSIC/com.ryanheise.audioservice.AudioServiceActivity} does not exist.
[   +1 ms] Waiting for VM Service port to be available...

I think the issue is related to the AndroidMainfest but I cannot understand where's the problem.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.lirmusic.LIRMUSIC"
    tools:ignore="Instantiatable">
    
    
    <uses-permission android:name="android.permission.INTERNET"/>
    <!-- ADD THESE TWO PERMISSIONS for just audio background -->
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <!-- ALSO ADD THIS PERMISSION for just audio background IF TARGETING SDK 34 -->
    <!-- <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/> -->

   <application
        android:usesCleartextTraffic="true"
        android:label="LIR MUSIC"
        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>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
            </intent-filter>
        </activity>

        <!-- ADD THIS "SERVICE" element -->
        <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>

        <!-- 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>

What could be causing this error, and how can I resolve it? Any insights or suggestions would be greatly appreciated. Thank you!

0

There are 0 best solutions below