您的主要 Activity 类 com.ryanheise.audioservice.AudioServiceActivity 不是 FlutterFragmentActivity 的子类

Ars*_*lik 3 android exception flutter just-audio flutter-stripe

我正在尝试使用 just_audio 和 just_audio_background 插件创建音乐应用程序,应用程序工作正常,但我正在尝试从 flutter_stripe 插件集成 Stripe。单击结账按钮时出现异常。它看起来像com.ryanheise.audioservice.AudioServiceActivityjust_audio_background 中的类与 flutter_stripe 插件冲突

异常 您的主活动类 com.ryanheise.audioservice.AudioServiceActivity 不是 FlutterFragmentActivity 的子类。

MainActivity.kt


package com.example.spotify
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity() {
}
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.spotify"
    xmlns:tools="http://schemas.android.com/tools">
   <uses-permission android:name="android.permission.INTERNET"/>
   <uses-permission android:name="android.permission.WAKE_LOCK"/>
   <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
   
   <application
        android:label="spotify"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true">
        <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">
            <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 -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    <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>     
    </application>
</manifest>

Run Code Online (Sandbox Code Playgroud)

`

我尝试直接将自定义活动定义到菜单中,但它不起作用。请帮助我,我是新手

Rya*_*ise 6

您可以尝试AudioServiceFragmentActivity代替AudioServiceActivity. 有关定义音频服务活动的不同方法的更多信息,请参阅audio_service 文档