Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError

Viewed 836

Getting some very odd behaviour on my Google Play Pre-Launch report, and it's only just started occurring, but I can't pin it down to anything I have changed. I also can't reproduce the issue myself.

Every test device seems to be failing in the pre-launch report (6/6 devices all fail the same way). However repeating the steps on the same build on a real device, I can never recreate it. The stack trace is as follows:

FATAL EXCEPTION: Thread-8
Process: uk.myapp.test, PID: 25312
java.lang.NoSuchMethodError: No static method createWithResource(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 base.apk)
    at androidx.core.app.NotificationCompat$Action.<init>(NotificationCompat.java:4572)
    at com.google.android.exoplayer2.ui.PlayerNotificationManager.createPlaybackActions(PlayerNotificationManager.java:1439)
    at com.google.android.exoplayer2.ui.PlayerNotificationManager.<init>(PlayerNotificationManager.java:757)
    at com.google.android.exoplayer2.ui.PlayerNotificationManager$Builder.build(PlayerNotificationManager.java:564)
    at uk.myapp.test.AudioPlayerService.onCreate(AudioPlayerService.java:96)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3570)
    at android.app.ActivityThread.access$1300(ActivityThread.java:200)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1672)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at androidx.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:10)
    at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:7)
    at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:1)
    at androidx.test.espresso.base.UiControllerImpl.injectMotionEvent(UiControllerImpl.java:5)
    at androidx.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:6)
    at androidx.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:1)
    at androidx.test.espresso.action.Tap.sendSingleTap(Tap.java:5)
    at androidx.test.espresso.action.Tap.-$$Nest$smsendSingleTap(Unknown Source:0)
    at androidx.test.espresso.action.Tap$1.sendTap(Tap.java:1)
    at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:4)
    at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:2)
    at androidx.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:21)
    at androidx.test.espresso.ViewInteraction.-$$Nest$mdoPerform(Unknown Source:0)
    at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:2)
    at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
3 Answers

Not exactly sure but I think it's an issue with the Robo tests that Firebase test lab uses. I haven't tried using their instrumented tests instead, but it's the only explanation I can currently think of.

EDIT: initially reverting to 29.0.2 release of Google Firebase BOM (from 29.0.3) fixed the issue for me, however problem has reared it's ugly head again, and excluding all firebase components doesn't fix it, so my original fix was merely a plaster.

I am now using Firebase Test Lab to conduct runs (it's much quicker than pushing builds to Google Play, and having to bump the number each time and wait a day). Firebase Test Lab fails the same way, and much quicker (you get 5 runs a day for free). I can now see that it's something related to R8 code obfuscation.

Setting minifyEnabled to false and it works just fine, setting it to true, it crashes every time.

So it appears to be be releated to this R8 bug: https://issuetracker.google.com/issues/213617215#comment22

For me, I have worked around this issue by adding this to my Proguard rules file. It now passes on Firebase Test Lab.

-keep class androidx.core.graphics.drawable.** { *; }

I implemented reverting the Firebase BOM version like the other answer suggested, but it didn't (or at least didn't fully resolve) the issue for me. Reverting this other dependency finished solving it for me:

Crashing version:

implementation 'com.google.android.gms:play-services-location:19.0.1'

Working version:

implementation 'com.google.android.gms:play-services-location:18.0.0'
Related