[Health 10.2.0] Android build with audio service
Device / Emulator and OS
Please complete the following information for each phone and/or emulator you're experiencing this bug on:
- Device: Moto g20
- OS: Android 14
Describe the bug
When i try to build a flutter app with audio_service and audio_session and health 10.2.0 the android build fails with the error message E/AndroidRuntime(29997): Caused by: java.lang.ClassCastException: com.ryanheise.audioservice.AudioServiceActivity cannot be cast to androidx.activity.ComponentActivity E/AndroidRuntime(29997): at cachet.plugins.health.HealthPlugin.onAttachedToActivity(HealthPlugin.kt:2418)
To Reproduce
Use Flutter 3.24.0 add audio_session, audio_background, just_audio and health latest
Expected behavior
The android app should build
Actual behavior
The android app doesnt builds
Uninstalling old version... E/AndroidRuntime(29997): FATAL EXCEPTION: main E/AndroidRuntime(29997): Process: com.harmoniehealthcare.harmonie.app, PID: 29997 E/AndroidRuntime(29997): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.harmoniehealthcare.harmonie.app/com.ryanheise.audioservice.AudioServiceActivity}: java.lang.ClassCastException: com.ryanheise.audioservice.AudioServiceActivity cannot be cast to androidx.activity.ComponentActivity E/AndroidRuntime(29997): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782) E/AndroidRuntime(29997): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922) E/AndroidRuntime(29997): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) E/AndroidRuntime(29997): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139) E/AndroidRuntime(29997): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96) E/AndroidRuntime(29997): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443) E/AndroidRuntime(29997): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(29997): at android.os.Looper.loopOnce(Looper.java:205) E/AndroidRuntime(29997): at android.os.Looper.loop(Looper.java:294) E/AndroidRuntime(29997): at android.app.ActivityThread.main(ActivityThread.java:8177) E/AndroidRuntime(29997): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(29997): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) E/AndroidRuntime(29997): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) E/AndroidRuntime(29997): Caused by: java.lang.ClassCastException: com.ryanheise.audioservice.AudioServiceActivity cannot be cast to androidx.activity.ComponentActivity E/AndroidRuntime(29997): at cachet.plugins.health.HealthPlugin.onAttachedToActivity(HealthPlugin.kt:2418) E/AndroidRuntime(29997): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.attachToActivityInternal(FlutterEngineConnectionRegistry.java:350) E/AndroidRuntime(29997): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.attachToActivity(FlutterEngineConnectionRegistry.java:323) E/AndroidRuntime(29997): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:208) E/AndroidRuntime(29997): at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:638) E/AndroidRuntime(29997): at android.app.Activity.performCreate(Activity.java:8595) E/AndroidRuntime(29997): at android.app.Activity.performCreate(Activity.java:8573) E/AndroidRuntime(29997): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456) E/AndroidRuntime(29997): at android.app.Act
Flutter doctor
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.24.0, on macOS 13.6.3 22G436 darwin-arm64, locale en-CO) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.2) [✓] VS Code (version 1.92.0) [✓] Connected device (5 available) ! Error: Browsing on the local area network for Apple Watch de Shirley juliana. Ensure the device is unlocked and discoverable via Bluetooth. (code -27) ! Error: Browsing on the local area network for users iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27) [✓] Network resources
• No issues found!