4

I recently released an app to Google Play, however I'm getting this error -

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)

The stack trace points to this line of code addAction(R.drawable.ic_baseline_close_24dp, context.getString(R.string.lbl_cancel), cancelIntent) in my NotificationUtils method

fun createNotificationBuilder(
    context: Context,
    notificationTitle: String,
    message: String?,
    channelId: String,
    channelName: String,
    contentIntent: PendingIntent = getMainLauncherIntent(context.applicationContext),
    cancelIntent: PendingIntent? = null,
    showProgress: Boolean = false,
    ongoing: Boolean = false,
    autoCancel: Boolean = true,
): NotificationCompat.Builder {
 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        createNotificationChannel(context.applicationContext, channelId, channelName)
    }
    val builder = NotificationCompat.Builder(context.applicationContext, channelId).apply {
        setContentTitle(notificationTitle)

        if (message != null) {
            setContentText(message)
        }

        setTicker(notificationTitle)
        setSmallIcon(R.drawable.ic_launcher_foreground)
        setContentIntent(contentIntent)
        setOngoing(ongoing)
        setOnlyAlertOnce(true)
        setAutoCancel(autoCancel)

        if (showProgress) {
            setProgress(MAX_PROGRESS, 0, false)
        }

        if (cancelIntent != null) {
           addAction(R.drawable.ic_baseline_close_24dp, context.getString(R.string.lbl_cancel), cancelIntent)
        }
    }

    return builder
}

However I can't seem to reproduce the issue. I see some other posts that mention they had some android support library in libs that was some older android support library, but I don't think I have any. I only have this swipe-reveal-layout library in my libs. My project can be found here.

Oliver Song
  • 103
  • 1
  • 5
  • Did you try downgrading the version of any related library? – Sujal Kumar Jan 07 '22 at 02:48
  • 1
    Also seeing the same issue, which makes it sound like a 3rd party library issue. My post: https://stackoverflow.com/questions/70622416/crash-on-google-play-pre-launch-report-java-lang-nosuchmethoderror?r=SearchResults&s=2|26.0111 – Mike Macpherson Jan 07 '22 at 22:19

1 Answers1

4

For me, this was related to the 29.0.3 release of Google Firebase BOM. (and/or the things changed in the BOM, if you don't use the BOM and use the specific components, if so, see the Firebase BOM release page for the package changes between releases)

Reverting from:

implementation com.google.firebase:firebase-bom:29.0.3

To:

implementation com.google.firebase:firebase-bom:29.0.2

Completely solved my issue. I hope this helps others.

If you aren't using BOM, then revert com.google.firebase:firebase-core and com.google.firebase:firebase-analytics both back to: 20.0.1

Mike Macpherson
  • 456
  • 4
  • 12