snowplow / snowplow/snowplow-java-tracker
Attempting to use both the Java and Android tracker in the same project causes DuplicateClass errors
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 25
- Forks
- 35
- Avg merge
- 52m
- Merged PRs (30d)
- 1
Description
Describe the bug
I have a library A that uses the java-tracker as a dependency. It's a pure Java project because it needs to be shared with other pure Java projects. That is to say it uses the Gradle java plugin.
I also have an application B that uses the android-tracker as a dependency. This uses the Gradle android-application plugin but otherwise contains a mix of Android libraries and Java libraries.
Both scenarios are valid until you try and use library A in application B as dependency. Gradle then complains that there is a DuplicateClass error.
Duplicate class com.snowplowanalytics. snowplow. tracker. DevicePlatform
found in modules
snowplow-android-tracker- 6. 0. 3. aar -> snowplow-android-tracker- 6. 0. 3- runtime (com.snowplowanalytics: snowplow-android- tracker: 6. 0. 3)
and
snowplow-java-tracker- 2. 1. 0. jar -> snowplow-java-tracker- 2. 1. 0 (com.snowplowanalytics: snowplow- java- tracker: 2. 1. 0)
To Reproduce
- Publish a pure Java library that depends on the Snowplow
java-trackerto your Maven Local repo. - Configure an Android application to additionally check your Maven Local repo.
repositories {
mavenLocal()
... // Other repos you might need
}
- Add to your Android application a dependency on the library that you published in Step 1.
- Add to your Android application a dependency on the Snowplow
android-tracker. - Build application.
Expected behaviour
The Android application can be successfully compiled with both the java-tracker and the android-tracker side by side.
Additional context
I originally wanted to use the android-tracker as a dependency to the library I am building (library A) but I cannot import an Android .aar into a project that only depends on Java. The usage of Snowplow in Library A is to send events about Library A independently of whatever application Library A may be embedded in - be that Java or Android.
It looks to me that it is only DevicePlatform (in the Java tracker, in the Android tracker) that causes the issue due to the matching namespace and class name.
I really like the android-tracker compared to the java-tracker as I mainly write Kotlin, but there isn't a way for me to build a pure Java SDK that can depend on the android-tracker at the moment and I realise refactoring the android-tracker to separate Android dependencies into another artefact (perhaps two Kotlin written SDKs called snowplow-core and snowplow-android) is a bit much to ask.
As a quick win would you consider renaming DevicePlatform in the java-tracker? Or moving it to a package that won't cause a collision?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/main/java/com/snowplowanalytics/snowplow/tracker/DevicePlatform.java in the Java tracker and compare it with the Android tracker counterpart linked in the issue. Reproduce the Maven Local and Android dependency setup to confirm the class collision and inspect the existing comments before choosing a compatible resolution. Done means an Android application can use a library depending on the Java tracker alongside the Android tracker without DuplicateClass errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100