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

标签 android flutter exception just-audio flutter-stripe

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

异常 您的 Main Activity 类 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() {
}

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>

`

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

最佳答案

您可以尝试 AudioServiceFragmentActivity 而不是 AudioServiceActivity。有关定义音频服务 Activity 的不同方法的更多信息,请参阅 audio_service documentation .

关于android - 您的主要 Activity 类 com.ryanheise.audioservice.AudioServiceActivity 不是 FlutterFragmentActivity 的子类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74694631/

相关文章:

dart - 在 Dart/Flutter 中定义变量并引用父上下文

java - 将InputMismatchException转换为用户定义的异常

python (2.7): Error Handling in __init__ with Sensitive Information

android - 在线性布局中对齐

java - FindViewById 循环

android - 限制 TextView 中的行数

android - 在 channel plugins.it_nomads.com/flutter_secure_storage 上找不到方法写入的实现

flutter - Flutter中OnChanged函数执行后调用Future

android - 网络通信中的 Activity 和 fragment 职责(robospice)

java - Intellij IDEA异常断点条件下调用自定义函数