elastic/apm-agent-android

Error with duplicate classes on "com.github.instacart.truetime-android:library"

Closed this issue ยท 7 comments

Hi,
We are trying to integrate our application with apm-agent-android. Unfortunately we are using "true-time" library. And You are exposing this library as ".jar" not as a standard dependency in pom.. That cause our project to have:
CheckDuplicatesRunnable
Duplicate class com.instacart.library.truetime.BootCompletedBroadcastReceiver found in modules android-sdk-0.9.0-runtime (co.elastic.apm:android-sdk:0.9.0) and library-3.4-runtime (com.github.instacart.truetime-android:library:3.4) Duplicate class com.instacart.library.truetime.CacheInterface found in modules android-sdk-0.9.0-runtime (co.elastic.apm:android-sdk:0.9.0) and library-3.4-runtime (com.github.instacart.truetime-android:library:3.4) Duplicate class com.instacart.library.truetime.DiskCacheClient found in modules android-sdk-0.9.0-runtime (co.elastic.apm:android-sdk:0.9.0) and library-3.4-runtime (com.github.instacart.truetime-android:library:3.4) Duplicate class com.instacart.library.truetime.InvalidNtpServerResponseException found in modules android-sdk-0.9.0-runtime (co.elastic.apm:android-sdk:0.9.0) and library-3.4-runtime (com.github.instacart.truetime-android:library:3.4) Duplicate class com.instacart.library.truetime.SharedPreferenceCacheImpl found in modules android-sdk-0.9.0-runtime (co.elastic.apm:android-sdk:0.9.0) and library-3.4-runtime (com.github.instacart.truetime-android:library:3.4) Duplicate class com.instacart.library.truetime.SntpClient found in modules android-sdk-0.9.0-runtime (co.elastic.apm:android-sdk:0.9.0) and library-3.4-runtime (com.github.instacart.truetime-android:library:3.4) Duplicate class com.instacart.library.truetime.TrueLog found in modules android-sdk-0.9.0-runtime (co.elastic.apm:android-sdk:0.9.0) and library-3.4-runtime (com.github.instacart.truetime-android:library:3.4) Duplicate class com.instacart.library.truetime.TrueTime found in modules android-sdk-0.9.0-runtime (co.elastic.apm:android-sdk:0.9.0) and library-3.4-runtime (com.github.instacart.truetime-android:library:3.4)

https://github.com/elastic/apm-agent-android/blob/main/android-sdk/build.gradle. Here You are exposing it as embedded 'com.github.instacart.truetime-android:library:3.5'. Our request would be to expose it as dependency. Nowadays many android application using "true-time" as dependency.

Best
Dominik

Hi @SpotOnDJ

Thank you for your input. The problem with adding true-time as a normal dependency is that it's not available in the mavenCentral repo, which is where our artifacts are and it's also a repo that comes built into any new Android project, so it doesn't seem right having to request our users to add JitPack (which some people consider as a security risk) to their repos just because we have that lib as a dependency.

We are also not sure if we'll keep using true-time in the near future. But in the meantime, I think we can still make some changes on our side in order to prevent this issue from happening. I'll work on a fix for it.

Thank You so much! Without removing true-time as jar, we cannot integrate with You. Will wait for fix

@LikeTheSalad Do you have any idea of a temporary workaround for this issue?

This issue got automatically closed after I merged a PR with the fix. However, I'd like to leave it open until we can confirm that the new build behaves as expected.

Do you have any idea of a temporary workaround for this issue?

@JakubMosakowski - I can't think of any workaround possible. Luckily the fix was quick, so I'm hoping to release a new build today.

Nice! Cool clean solution with shadowing and repackages! ๐Ÿš€

The new version 0.11.0 is out now where this should be fixed ๐Ÿ‘ Thank you for your patience and please let us know if for some reason the issue persists.

I'm going to close this issue, feel free to reopen it if needed.