-
-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android R8 seems to alter the tag name when companion object extends KLogging() #115
Comments
It might be so. You can try the alternative syntax of file level field if that helps. |
Sorry for the late reply, the issue occurs only when R8 is enabled. I have created a clean sample project that reproduces the issue in release build variant, I'm grateful if you can try to debug the issue. |
@1951FDG Thanks, can you please add the steps to reproduce the issue in that repo? |
@1951FDG I am still not sure what are the steps to reproduce the issue. |
Sorry for the delay again
The GUI of the app will show a text field, which is set to the name of the logger, When active build is release build, the text field will show: When active build is debug build, the text field will show: The issue occurs in release build when R8 (shrinker in the Android build process) is on (minifyEnabled == true) |
The minification process caused the companion object to have different characteristics than a usual Kotlin Companion object. Since we are using a fragile mechanism that uses reflection, it doesn't work for this case, and I am not sure it is worth allowing it as it might break other use cases.
Please let me know if that is good enough as a solution. |
Thanks, this works perfectly! Maybe include this info in the documentation for Android devs... |
Added it here to the wiki. |
Hello,
Thanks for this library, I'm using it :)
I have a class MainActivity with a companion object that extends KLogging():
I noticed that the tag name changes when R8 is on:
When R8 is on: io.github.getsixtyfour.openpyn.
MainActivity$b
When R8 is off: io.github.getsixtyfour.openpyn.
MainActivity
Browsing the code I noticed that KLoggerNameResolver is responsible for unwrapping the companion class to the enclosing class, I am however uncertain if there is a bug in the implementation or if R8 is doing something funky of which I am unfamiliar with...
Thanks
The text was updated successfully, but these errors were encountered: