Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.ryanheise.audioservice.AudioServiceActivity cannot be cast to androidx.fragment.app.FragmentActivity

when i use just_audio_background and PsPdfKit together then this issue is coming just_audio_background needs

android:name="com.ryanheise.audioservice.AudioServiceActivity"

in androidManifest.xml

i tried to change

android:name="com.ryanheise.audioservice.AudioServiceActivity"

to android:name = ".MainActivity" and also tried

android:name = "io.flutter.embedding.android.FlutterAppCompatActivity"

but with these changes its not building from android and one more thing its working fine for ios

like image 858
user5755843 Avatar asked Oct 22 '25 07:10

user5755843


1 Answers

Instead of modifying the android.name, you can implement in MainActivity:

import android.content.Context;
import com.ryanheise.audioservice.AudioServicePlugin;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;


public class MainActivity extends FlutterActivity {
  @Override
  public FlutterEngine provideFlutterEngine(Context context) {
    return AudioServicePlugin.getFlutterEngine(context);
  }
}
like image 62
adrianvintu Avatar answered Oct 25 '25 00:10

adrianvintu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!