Skip to content
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

Unable to remove DebugMetadata annotation with ProGuard #2267

Closed
kober32 opened this issue Sep 25, 2020 · 4 comments
Closed

Unable to remove DebugMetadata annotation with ProGuard #2267

kober32 opened this issue Sep 25, 2020 · 4 comments
Labels

Comments

@kober32
Copy link

kober32 commented Sep 25, 2020

I have an app that is being obfuscated and shrunk by R8 (not a fullMode). Even after that the kotlin.coroutines.jvm.internal.DebugMetadata class is kept (obfuscated) above every class that is using coroutines.

As I went through the documentation and other issues, I found zero references about how to get rid of this annotation that (as names suggest) shouldn't be there on a release build.

The code after the R8:

    @nb1(c = "my.path.to.package.ActivationManager$removeActivationRemotely$2", f = "ActivationManager.kt", l = {286, 290}, m = "invokeSuspend")
    static final class g extends sb1 implements qc1<h0, ya1<? super d91>, Object> {
        private h0 j;
        Object k;
        Object l;
        Object m;
...

Is there a way how to get rid of it other than just getting rid of the coroutines altogether?

@elizarov
Copy link
Contributor

It looks like an R8 problem. I'd suggest to report it to the R8 team.

@Thomas-Vos
Copy link
Contributor

I have the following in my R8 rules that removes the annotation for me:

# Ensure the DebugMetadata annotation is not included in the APK.
-checkdiscard @interface kotlin.coroutines.jvm.internal.DebugMetadata
-assumenosideeffects public class kotlin.coroutines.jvm.internal.BaseContinuationImpl {
  private kotlin.coroutines.jvm.internal.DebugMetadata getDebugMetadataAnnotation() return null;
  public java.lang.StackTraceElement getStackTraceElement() return null;
  public java.lang.String[] getSpilledVariableFieldMapping() return null;
}

There is some more information in the following issue: https://issuetracker.google.com/issues/155947700

@qwwdfsad
Copy link
Member

Please follow the linked issue on Google tracker, this is indeed an R8 problem

@vvb2060
Copy link

vvb2060 commented Jun 25, 2022

Should these rules be added to coroutines.pro?

# Statically turn off all debugging facilities and assertions
-assumenosideeffects class kotlinx.coroutines.DebugKt {
boolean getASSERTIONS_ENABLED() return false;
boolean getDEBUG() return false;
boolean getRECOVER_STACK_TRACES() return false;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants