rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.22k stars 839 forks source link

[Bug]: Compilation failed on Android (Duplicated classes) #2775

Closed azuken closed 1 year ago

azuken commented 1 year ago

Mapbox Implementation

Mapbox

Mapbox Version

default

Platform

Android

@rnmapbox/maps version

10.0.0-rc.8

Standalone component to reproduce

import React from 'react';
import {
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
} from '@rnmapbox/maps';

const aLine = {
  type: 'LineString',
  coordinates: [
    [-74.00597, 40.71427],
    [-74.00697, 40.71527],
  ],
};

class BugReportExample extends React.Component {
  render() {
    return (
      <MapView style={{flex: 1}}>
        <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
        <ShapeSource id="idStreetLayer" shape={aLine}>
          <LineLayer id="idStreetLayer" />
        </ShapeSource>
      </MapView>
    );
  }
}

Observed behavior and steps to reproduce

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDevelopmentDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.mapbox.android.core.location.LocationEngine found in modules jetified-common-23.4.0-runtime (com.mapbox.common:common:23.4.0) and jetified-mapbox-android-core-4.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:4.0.0)
     Duplicate class com.mapbox.android.core.location.LocationEngineCallback found in modules jetified-common-23.4.0-runtime (com.mapbox.common:common:23.4.0) and jetified-mapbox-android-core-4.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:4.0.0)
     Duplicate class com.mapbox.android.core.location.LocationEngineProvider found in modules jetified-common-23.4.0-runtime (com.mapbox.common:common:23.4.0) and jetified-mapbox-android-core-4.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:4.0.0)
     Duplicate class com.mapbox.android.core.location.LocationEngineRequest found in modules jetified-common-23.4.0-runtime (com.mapbox.common:common:23.4.0) and jetified-mapbox-android-core-4.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:4.0.0)
     Duplicate class com.mapbox.android.core.location.LocationEngineRequest$1 found in modules jetified-common-23.4.0-runtime (com.mapbox.common:common:23.4.0) and jetified-mapbox-android-core-4.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:4.0.0)
     Duplicate class com.mapbox.android.core.location.LocationEngineRequest$Builder found in modules jetified-common-23.4.0-runtime (com.mapbox.common:common:23.4.0) and jetified-mapbox-android-core-4.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:4.0.0)
     Duplicate class com.mapbox.android.core.location.LocationEngineResult found in modules jetified-common-23.4.0-runtime (com.mapbox.common:common:23.4.0) and jetified-mapbox-android-core-4.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:4.0.0)
     Duplicate class com.mapbox.android.core.permissions.PermissionsListener found in modules jetified-common-23.4.0-runtime (com.mapbox.common:common:23.4.0) and jetified-mapbox-android-core-4.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:4.0.0)
     Duplicate class com.mapbox.android.core.permissions.PermissionsManager found in modules jetified-common-23.4.0-runtime (com.mapbox.common:common:23.4.0) and jetified-mapbox-android-core-4.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:4.0.0)

     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 43s

    at makeError (/XXXX/mobile/node_modules/execa/index.js:174:9)
    at /XXXX/mobile/node_modules/execa/index.js:278:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runOnAllDevices (/XXXX/mobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:82:7)
    at async Command.handleAction (/XXXX/mobile/node_modules/@react-native-community/cli/build/index.js:108:9)
info Run CLI with --verbose flag for more details.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.

Expected behavior

App must compile and launch

Notes / preliminary analysis

No response

Additional links and references

No response

mfazekas commented 1 year ago

Pls use the setup template, but only if you can reproduce with a brand new project create with react-native init and be sure to include all steps required to reproduce the issue

azuken commented 1 year ago

Thanks for the help... I have used the setup template, followed all the steps. It fails only when I try to use "mapbox" implementation.

azuken commented 1 year ago

Ok I found the issue, in case someone has the same behaviour.

I had a mapbox telemetry dependency line in app build.gradle

implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:7.0.0'

Remove it solved the issue.

tomskopek commented 1 year ago

Thanks @azuken, that helped me upgrade. I don't think I would have found that on my own 🙏