florent37 / Flutter-AssetsAudioPlayer

Play simultaneously music/audio from assets/network/file directly from Flutter, compatible with android / ios / web / macos, displays notifications
https://pub.dartlang.org/packages/assets_audio_player
Apache License 2.0
740 stars 337 forks source link

Crash on app startup on Google Pixel 6/7 after version 3.0.6 #797

Closed nohli closed 10 months ago

nohli commented 10 months ago

Flutter Version

My version : 3.10.6

Lib Version

My version : 3.1.0 (all >3.0.6)

Platform (Android / iOS / web) + version

Platform : Android

Describe the bug

A lot of crashes on app start in production.

Another report: https://github.com/florent37/Flutter-AssetsAudioPlayer/pull/788#issuecomment-1691224515

Google Pixel 7 emulator with latest plugin version:

E/AndroidRuntime(10514): FATAL EXCEPTION: main
E/AndroidRuntime(10514): Process: com.achimsapps.breathe, PID: 10514
E/AndroidRuntime(10514): java.lang.RuntimeException: Unable to create service com.github.florent37.assetsaudioplayer.notification.NotificationService: java.lang.ClassNotFoundException: Didn't find class "com.github.florent37.assetsaudioplayer.notification.NotificationService" on path: DexPathList[[zip file "/data/app/~~kgy5JKFVcghG3gF_a2Qbfw==/com.achimsapps.breathe-iWR5QDiXJqtaaVq9EKTGPg==/base.apk"],nativeLibraryDirectories=[/data/app/~~kgy5JKFVcghG3gF_a2Qbfw==/com.achimsapps.breathe-iWR5QDiXJqtaaVq9EKTGPg==/lib/arm64, /data/app/~~kgy5JKFVcghG3gF_a2Qbfw==/com.achimsapps.breathe-iWR5QDiXJqtaaVq9EKTGPg==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
E/AndroidRuntime(10514):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4498)
E/AndroidRuntime(10514):    at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
E/AndroidRuntime(10514):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2161)
E/AndroidRuntime(10514):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(10514):    at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(10514):    at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(10514):    at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(10514):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(10514):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(10514):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
E/AndroidRuntime(10514): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.github.florent37.assetsaudioplayer.notification.NotificationService" on path: DexPathList[[zip file "/data/app/~~kgy5JKFVcghG3gF_a2Qbfw==/com.achimsapps.breathe-iWR5QDiXJqtaaVq9EKTGPg==/base.apk"],nativeLibraryDirectories=[/data/app/~~kgy5JKFVcghG3gF_a2Qbfw==/com.achimsapps.breathe-iWR5QDiXJqtaaVq9EKTGPg==/lib/arm64, /data/app/~~kgy5JKFVcghG3gF_a2Qbfw==/com.achimsapps.breathe-iWR5QDiXJqtaaVq9EKTGPg==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
E/AndroidRuntime(10514):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
E/AndroidRuntime(10514):    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(10514):    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(10514):    at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:129)
E/AndroidRuntime(10514):    at androidx.core.app.CoreComponentFactory.instantiateService(CoreComponentFactory.java:75)
E/AndroidRuntime(10514):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4467)
E/AndroidRuntime(10514):    ... 9 more

Steps to reproduce

  1. Flutter create ...
  2. Add assets_audio_player: ^3.1.0 to pubspec.yaml or
    assets_audio_player:
     git:
       url: https://github.com/florent37/Flutter-AssetsAudioPlayer.git
       ref: fix-startup-crash-issue
  3. Add multidex support to make it run: android/app/build/gradle:
    defaultConfig {
       ...
       multiDexEnabled true
    }
  4. Open Android emulator Pixel 7 API 33 (create a new one, or wipe the data of your existing one)
  5. Run app
kalismeras61 commented 10 months ago

@nohli i don't have real device, i just tested with emulator Pixel 6 and 7 and i don't have any issue

nohli commented 10 months ago

@kalismeras61, this issue doesn't occur on a local Pixel 6 emulator on my side either. I've updated the steps to reproduce the problem.

kalismeras61 commented 10 months ago

@nohli can you try fix startup crash issue branch ?

https://github.com/florent37/Flutter-AssetsAudioPlayer/tree/fix-startup-crash-issue

nohli commented 10 months ago

Unfortunately still the same exception

E/AndroidRuntime(14742): FATAL EXCEPTION: main
E/AndroidRuntime(14742): Process: com.example.audioplayer_test, PID: 14742
E/AndroidRuntime(14742): java.lang.RuntimeException: Unable to create service com.github.florent37.assetsaudioplayer.notification.NotificationService: java.lang.ClassNotFoundException: Didn't find class "com.github.florent37.assetsaudioplayer.notification.NotificationService" on path: DexPathList[[zip file "/data/app/~~XMy4v6ZU4DnhnvM_PxBQyA==/com.example.audioplayer_test-s6vgELe2m4pyAP_BVEmEFw==/base.apk"],nativeLibraryDirectories=[/data/app/~~XMy4v6ZU4DnhnvM_PxBQyA==/com.example.audioplayer_test-s6vgELe2m4pyAP_BVEmEFw==/lib/arm64, /data/app/~~XMy4v6ZU4DnhnvM_PxBQyA==/com.example.audioplayer_test-s6vgELe2m4pyAP_BVEmEFw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
E/AndroidRuntime(14742):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4498)
E/AndroidRuntime(14742):    at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
E/AndroidRuntime(14742):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2161)
E/AndroidRuntime(14742):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(14742):    at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(14742):    at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(14742):    at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(14742):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(14742):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(14742):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
E/AndroidRuntime(14742): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.github.florent37.assetsaudioplayer.notification.NotificationService" on path: DexPathList[[zip file "/data/app/~~XMy4v6ZU4DnhnvM_PxBQyA==/com.example.audioplayer_test-s6vgELe2m4pyAP_BVEmEFw==/base.apk"],nativeLibraryDirectories=[/data/app/~~XMy4v6ZU4DnhnvM_PxBQyA==/com.example.audioplayer_test-s6vgELe2m4pyAP_BVEmEFw==/lib/arm64, /data/app/~~XMy4v6ZU4DnhnvM_PxBQyA==/com.example.audioplayer_test-s6vgELe2m4pyAP_BVEmEFw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
E/AndroidRuntime(14742):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
E/AndroidRuntime(14742):    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(14742):    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(14742):    at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:129)
E/AndroidRuntime(14742):    at androidx.core.app.CoreComponentFactory.instantiateService(CoreComponentFactory.java:75)
E/AndroidRuntime(14742):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4467)
E/AndroidRuntime(14742):    ... 9 more
kalismeras61 commented 10 months ago

@nohli can you put here your whole build.gradle file ?

nohli commented 10 months ago

As mentioned in the steps to reproduce, the vanilla gradle file from flutter create already has this issue.

The only necessary change was adding multidex true to android/app/build.gradle for the project to build.

kalismeras61 commented 10 months ago

As mentioned in the steps to reproduce, the vanilla gradle file from flutter create already has this issue.

The only necessary change was adding multidex true to android/app/build.gradle for the project to build.

Yes i know, as i said, i can't reproduce it, if you are using minified in your build gradle maybe it is removing some classes. That's why i asked.

nohli commented 10 months ago

Also not with Pixel 7 API 33 with Google Play?

I'm using Flutter 3.10.6 and an Apple Silicon Mac. The crashes were in production built with Codemagic, so not only a local issue.

@kalismeras61 I just tried it, and the app worked without issues. Then created another fresh app, and it also worked. Then wiped the data of the emulator, then it started failing again. So please make sure to wipe the data first.

nohli commented 10 months ago

@blueeyestw let's track the issue over here 😊

Have a couple of questions, just to make sure:

  1. In your latest app version, what's the version for assets_audio_player in pubspec.lock (a ^3.0.6 in pubspec.yaml means >=3.0.6 <4.0.0 and would use 3.1.0)?
  2. Are you experiencing the same amount of crashes, or less?
  3. Can you reproduce the issue locally (like in the steps to reproduce, or just run your own app)?
Kaushalrajpopat commented 4 months ago

@nohli @florent37 @kalismeras61

Hi is there any solution for this I am facing the same issue please refer to the below crash logs

Fatal Exception: java.lang.RuntimeException: Unable to create service com.github.florent37.assetsaudioplayer.notification.NotificationService: java.lang.ClassNotFoundException: Didn't find class "com.github.florent37.assetsaudioplayer.notification.NotificationService" on path: DexPathList[[zip file "/data/app/~~H0pvMZl2fKTADMS8ObAP-Q==/com.vidola.gapp.customer-pBT37hxAUvTwp_A35tr5PQ==/base.apk", zip file "/data/app/~~H0pvMZl2fKTADMS8ObAP-Q==/com.vidola.gapp.customer-pBT37hxAUvTwp_A35tr5PQ==/split_config.arm64_v8a.apk", zip file "/data/app/~~H0pvMZl2fKTADMS8ObAP-Q==/com.vidola.gapp.customer-pBT37hxAUvTwp_A35tr5PQ==/split_config.en.apk", zip file "/data/app/~~H0pvMZl2fKTADMS8ObAP-Q==/com.vidola.gapp.customer-pBT37hxAUvTwp_A35tr5PQ==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/~~H0pvMZl2fKTADMS8ObAP-Q==/com.vidola.gapp.customer-pBT37hxAUvTwp_A35tr5PQ==/lib/arm64, /data/app/~~H0pvMZl2fKTADMS8ObAP-Q==/com.vidola.gapp.customer-pBT37hxAUvTwp_A35tr5PQ==/base.apk!/lib/arm64-v8a, /data/app/~~H0pvMZl2fKTADMS8ObAP-Q==/com.vidola.gapp.customer-pBT37hxAUvTwp_A35tr5PQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/~~H0pvMZl2fKTADMS8ObAP-Q==/com.vidola.gapp.customer-pBT37hxAUvTwp_A35tr5PQ==/split_config.en.apk!/lib/arm64-v8a, /data/app/~~H0pvMZl2fKTADMS8ObAP-Q==/com.vidola.gapp.customer-pBT37hxAUvTwp_A35tr5PQ==/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64, /vendor/lib64, /odm/lib64, /my_product/lib64, /my_region/lib64]] at android.app.ActivityThread.handleCreateService(ActivityThread.java:4572) at android.app.ActivityThread.access$100(ActivityThread.java:299) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2207) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:264) at android.app.ActivityThread.main(ActivityThread.java:8312) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)