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

Duplicate classes errors after adding a dependency on tink-android #301

Open
oakkitten opened this issue Jan 21, 2024 · 1 comment
Open

Comments

@oakkitten
Copy link
Contributor

Using 2.2.21 from Jitpack, I'm running into build issues with my Android app after adding a dependency of androidx.security:security-crypto, which itself depends on com.google.crypto.tink:tink-android, with errors such as:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:checkDebugDuplicateClasses'.
    ...
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
    ...
Caused by: java.lang.RuntimeException: 
    Duplicate class com.google.crypto.tink.PublicKeySign found in modules jetified-sshlib-2.2.21 (com.github.connectbot:sshlib:2.2.21) and jetified-tink-android-1.7.0 (com.google.crypto.tink:tink-android:1.7.0)
    Duplicate class com.google.crypto.tink.PublicKeyVerify found in modules jetified-sshlib-2.2.21 (com.github.connectbot:sshlib:2.2.21) and jetified-tink-android-1.7.0 (com.google.crypto.tink:tink-android:1.7.0)
    Duplicate class com.google.crypto.tink.annotations.Alpha found in modules jetified-sshlib-2.2.21 (com.github.connectbot:sshlib:2.2.21) and jetified-tink-android-1.7.0 (com.google.crypto.tink:tink-android:1.7.0)
    ...

I tried excluding the tink dependcies of sshlib, which didn't work, and after running ./gradlew project:dependencies I see that sshlib does not have any dependencies. I looked through the build file and I see that sshlib uses Gradle Shadow, might that be the issue?

I'm quite unfamiliar with Shadow and Gradle generally causes me a lot of misery. Any ideas how I should proceed? And sorry if this is something stupid.

@oakkitten
Copy link
Contributor Author

oakkitten commented Feb 11, 2024

This seems to be solvable after reverting 1257f13. After reverting, I was able to do

// project relay uses sshlib
implementation(project(":relay")) {
    exclude("com.google.crypto.tink", "tink")
}

implementation("com.google.crypto.tink:tink-android:1.8.0")

Also, removing Shadow leads to APK size decreasing by 767 bytes (AGP 8.2.2, R8 in full mode)! Yay...

An alternative approach could be package relocation maybe. But so far everything seems to work

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

No branches or pull requests

1 participant