Skip to content

Android build fails with "Duplicate class com.caverock.androidsvg" caused by conflicting androidsvg JAR and AAR variants #378

Description

@carloswitei

Description

Building for Android fails at checkDebugDuplicateClasses because @d11/react-native-fast-image pulls in two incompatible variants of the same library simultaneously:

  • com.caverock:androidsvg:1.4 (JAR) — declared directly in the package's android/build.gradle
  • com.caverock:androidsvg-aar:1.4 (AAR) — pulled in transitively via com.github.penfeizhou.android.animation:glide-plugin:3.0.5

Both artifacts contain the exact same Java classes, which causes Android Gradle's duplicate class check to fail.

Steps to reproduce

  1. Create a React Native project with Expo (SDK 54, newArchEnabled: true)
  2. Install @d11/react-native-fast-image: npm install @d11/react-native-fast-image
  3. Run: expo run:android
  4. Build fails at Task :app:checkDebugDuplicateClasses

Expected behavior

The Android build completes successfully without duplicate class errors.
The package should use com.caverock:androidsvg-aar:1.4 consistently (the AAR variant), since glide-plugin already brings it transitively. Including the separate JAR variant (com.caverock:androidsvg:1.4) is redundant and causes a conflict.

Stacktrace or Logs

FAILURE: Build failed with an exception.

  * What went wrong:
  Execution failed for task ':app:checkDebugDuplicateClasses'.
  > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
     > Duplicate class com.caverock.androidsvg.BuildConfig found in modules androidsvg-1.4.jar -> androidsvg-1.4 (com.caverock:androidsvg:1.4) and
  androidsvg-aar-1.4.aar -> androidsvg-aar-1.4-runtime (com.caverock:androidsvg-aar:1.4)
       Duplicate class com.caverock.androidsvg.CSSParseException found in modules androidsvg-1.4.jar -> androidsvg-1.4 (com.caverock:androidsvg:1.4) and
  androidsvg-aar-1.4.aar -> androidsvg-aar-1.4-runtime (com.caverock:androidsvg-aar:1.4)
       Duplicate class com.caverock.androidsvg.SVG found in modules androidsvg-1.4.jar -> androidsvg-1.4 (com.caverock:androidsvg:1.4) and androidsvg-aar-1.4.aar ->
  androidsvg-aar-1.4-runtime (com.caverock:androidsvg-aar:1.4)
       [... dozens more classes from com.caverock.androidsvg package ...]

Output of npx react-native info

react-native: 0.81.5
expo: 54.0.31
@d11/react-native-fast-image: 8.13.0
Node: v24.13.0
Java: OpenJDK 17.0.18
OS: Ubuntu 24.04.4 LTS

Affected React-Native Architecture

New Architecture

Affected Platforms

Runtime - Android

Reproducer

https://github.com/dream-sports-labs/react-native-fast-image/blob/main/android/build.gradle

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions