audio_service icon indicating copy to clipboard operation
audio_service copied to clipboard

android icon - Crash appearing in crashalytics

Open yringler opened this issue 3 years ago • 11 comments

Documented behaviour

MediaControl.androidIcon

Actual behaviour

Crash

Runtime error

Fatal Exception: java.lang.NoSuchMethodError: No static method h(Landroid/content/res/Resources;Ljava/lang/String;I)Landroidx/core/graphics/drawable/IconCompat; in class Landroidx/core/graphics/drawable/IconCompat; or its super classes (declaration of 'androidx.core.graphics.drawable.IconCompat' appears in /data/app/~~_RcnCR0OtbJmY6pt9Y5eoQ==/androidx.test.tools.crawler-5YLxh2u69guHW7GNnn2Oyg==/base.apk)
       at androidx.core.app.NotificationCompat$Action.<init>(NotificationCompat.java:6)
       at com.ryanheise.audioservice.AudioService.createAction(AudioService.java:10)
       at com.ryanheise.audioservice.AudioService.setState(AudioService.java:60)
       at com.ryanheise.audioservice.AudioServicePlugin$AudioHandlerInterface.onMethodCall(AudioServicePlugin.java:469)
       at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:17)
       at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:18)
       at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0(DartMessenger.java:20)
       at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java)
       at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$6ZD1MYkhaLxyPjtoFDxe45u43DI.run(-.java:12)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:223)
       at android.app.ActivityThread.main(ActivityThread.java:7664)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Minimal reproduction project

https://github.com/yringler/inside-app

Reproduction steps

N/A

Output of flutter doctor

TODO

Devices exhibiting the bug

Android only 8.0.0 Galaxy S9 (2 times) 9 Pixel 3 (2 times) 11 Pixel 5 (2 times) 10 Galaxy S20 5G (2 times)

yringler avatar Jan 07 '22 15:01 yringler

One thing it might be is this commit:

https://github.com/ryanheise/audio_service/commit/6c29b4cbce37e96977ffaa69a9e0731e63157128#diff-c86bb6d0df8057eadc2afad5f1530768eb9e001425e99a9b27ebf71fcfebc79d

where the androidx.media:media dependency was removed. Since it didn't cause a build error at the time, this wasn't flagged, but it's possibly this that is now showing up as a runtime error.

ryanheise avatar Jan 07 '22 15:01 ryanheise

Ah, so you mean removing androidx.media:media wasn't necessarily super intentional? I haven't had a chance to try to reproduce the error, but is it worth it to add that dependency back and see if I stop seeing the crash?

I have a lot of balls in the air, a reason why I haven't focused on this properly yet. It happens to be a very busy time in my app development, There's been several public, beta, and internal releases in the last few weeks, but all app versions have the latest audio service - I had to upgrade because of android 12. #836

Just noticed that this crash has only been reported on versions of the app in internal testing. Which is strange, because it's a large variety of devices, and only one person should have access to internal testing, and he hasn't reported anything.

I have emulators I use during development, but only 2, and I haven't seen any crashes, and I don't think any of these are my type of device.

yringler avatar Jan 07 '22 15:01 yringler

Ah, so you mean removing androidx.media:media wasn't necessarily super intentional? I haven't had a chance to try to reproduce the error, but is it worth it to add that dependency back and see if I stop seeing the crash?

Definitely that would be the first thing to try. Is there any other information you can provide about your build process for Android? I assume this is a release build, but how was that release build built? E.g. APK / app bundle, obfuscation, anything special in build.gradle, other gradle or pub dependencies that might transitively depend on conflicting media dependencies, etc.

Also reproducing it is important in order to know for sure whether the fixes it. If you want to just try that proposed change and see how it goes, maybe that will be easier for you.

ryanheise avatar Jan 08 '22 02:01 ryanheise

Edit: happened in public beta

yringler avatar Jan 09 '22 01:01 yringler

where the androidx.media:media dependency was removed

I still see the dependency in that commit and master?

yringler avatar Jan 09 '22 02:01 yringler

Sorry, I think I meant androids.core:core.

ryanheise avatar Jan 09 '22 02:01 ryanheise

I build with code magic, an app bundle and APK I don't think I have anything special in my build.gradle All the stuff is here

Sorry, I think I meant androids.core:core.

Ah, ok. I may just add that back and see if I stop seeing errors. Haven't been able to replicate yet.

yringler avatar Jan 09 '22 02:01 yringler

Haven't been able to replicate - tried same build, same device (browserstack - free open source license), no dice :grimacing: I've never been so nervous not to see a crash :laughing: Big release coming up this week.

yringler avatar Jan 09 '22 03:01 yringler

It is a strange one because it appears that the same build is sometimes working and sometimes not. Perhaps this has to do with the way Android libraries are loaded and that maybe they are loaded in different ways at different times. For example, if the entry point is the main activity or if the entry point is from a background trigger. Do you have test cases for each?

ryanheise avatar Jan 09 '22 04:01 ryanheise

Do you have test cases for each?

I... don't have test cases Very embarrassing.

I could try a background trigger, but not sure what that means. That would be for example, if I play audio, kill the app, and then click the notification?

yringler avatar Jan 09 '22 04:01 yringler

Yes, although I guess that scenario would behave differently pre and post Android 11, so I'm not 100% if it will lead to anything.

ryanheise avatar Jan 09 '22 06:01 ryanheise