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

Release build with R8 fails without #619

Open
Anigif opened this issue Jun 20, 2023 · 3 comments
Open

Release build with R8 fails without #619

Anigif opened this issue Jun 20, 2023 · 3 comments
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.

Comments

@Anigif
Copy link

Anigif commented Jun 20, 2023

Describe the bug
After bumping to 5.2 (5.1 works) we get this error while building in release mode with minify enabled:

WARNING: [app-module-path]/build/intermediates/merged_java_res/release/base.jar: R8: Unexpected reference to missing service class: META-INF/services/com.google.protobuf.GeneratedExtensionRegistryLoader.
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in [app-module-path]/build/outputs/mapping/release/missing_rules.txt.
ERROR: R8: Missing class com.android.installreferrer.api.InstallReferrerClient$Builder (referenced from: void com.snowplowanalytics.core.tracker.InstallReferrerDetails$Companion.fetch(android.content.Context, kotlin.jvm.functions.Function1))
Missing class com.android.installreferrer.api.InstallReferrerClient (referenced from: com.android.installreferrer.api.InstallReferrerClient com.snowplowanalytics.core.tracker.InstallReferrerDetails$Companion$fetch$1.$referrerClient and 2 other contexts)
Missing class com.android.installreferrer.api.InstallReferrerStateListener (referenced from: void com.snowplowanalytics.core.tracker.InstallReferrerDetails$Companion.fetch(android.content.Context, kotlin.jvm.functions.Function1) and 1 other context)

The content of missing_rules.txt is:

# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn com.android.installreferrer.api.InstallReferrerClient$Builder
-dontwarn com.android.installreferrer.api.InstallReferrerClient
-dontwarn com.android.installreferrer.api.InstallReferrerStateListener

To Reproduce
Bump to 5.2 and don't add the installreferrer dependency.

Additional context
We haven't understood it as required and we're not sure we want to log that particular entity.

@Anigif Anigif added the type:defect Bugs or weaknesses. The issue has to contain steps to reproduce. label Jun 20, 2023
@matus-tomlein
Copy link
Contributor

Hi @Anigif, thanks for reporting the issue!

The installreferrer dependency is indeed an optional dependency – if it is not added to your project, the tracker will not call it's APIs and won't track the entity.

I can reproduce the message about missing classes when building an app withe minify, but it is only reported as a warning in my case. Do you have some setting enabled that turns warnings into errors?

@Anigif
Copy link
Author

Anigif commented Jun 21, 2023

Yeah, think that's true. I'm not 100% sure what flag causes this, but we have various settings that sets warnings as errors. So in theory it should be safe to ignore these warnings as a workaround?

@matus-tomlein
Copy link
Contributor

Yes, exactly, it is safe to ignore the warning because the tracker checks for the presence of classes in the package and if they are not present, it does not use them at all.

It would be ideal if we could find a way to avoid the warnings but, to be honest, I wasn't able to figure out how to do that. I haven't found a way to remove certain code (such as you would with a Macro in C-like languages) from the package if the required package is not present. If anyone has ideas how to achieve that, please let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.
Projects
None yet
Development

No branches or pull requests

2 participants