Missing class org.slf4j.impl.StaticLoggerBinder (referenced from: void org.slf4j.LoggerFactory.bind() and 3 other contexts) when using Pusher library
Asked Answered
O

2

7

with R8 enabled (isMinifyEnabled = true) and using "com.pusher.pusher-java-client:2.4.4" library I get the following error for release build:

AGPBI: {"kind":"error","text":"Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in project\app\build\outputs\mapping\devRelease\missing_rules.txt.","sources":[{}]} AGPBI: {"kind":"error","text":"Missing class org.slf4j.impl.StaticLoggerBinder (referenced from: void org.slf4j.LoggerFactory.bind() and 3 other contexts)","sources":[{}],"tool":"R8"} Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in project\app\build\outputs\mapping\devRelease\missing_rules.txt.

Missing class org.slf4j.impl.StaticLoggerBinder (referenced from: void org.slf4j.LoggerFactory.bind() and 3 other contexts)

How can I solve it? With isMinifyEnabled = false it builds without issues

Overweary answered 28/4, 2023 at 10:34 Comment(1)
There is also a YouTrack issue for reference: youtrack.jetbrains.com/issue/KTOR-5528/….Straub
O
26

Fixed by adding the following rule:

##---------------Begin: proguard configuration for Pusher Java Client  ----------
-dontwarn org.slf4j.impl.StaticLoggerBinder
##---------------End: proguard configuration for Pusher Java Client  ----------
Overweary answered 28/4, 2023 at 10:42 Comment(1)
Thanks it worked. Btw, may i know what is this actually ? I'n not seeing anywhere i have used this. Will this use by internally ?Iamb
O
2

you might be using some dependency that adds this rule -keep org.slf4j.impl.StaticLoggerBinder(in my case it was Algolia which has a transitive dependency on the Ktor client). Since proguard rules are additive all the gets added in the final app rule. This -keep rule also gets added to the final rule.

Now it might be that you don't have the class present in the Android compile time classpath(as these logger factories need to be added via the Service loader mechanism). That is why you are getting this error

Adding -dontwarn org.slf4j.impl.StaticLoggerBinder is safe thing to do here

Orelee answered 26/5 at 10:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.