Skip to content

[Bug]: On Android, onLongPress function is working only once(initial render) #3715

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

Open
vaishnavi-techp opened this issue Dec 5, 2024 · 21 comments · May be fixed by #3847
Open

[Bug]: On Android, onLongPress function is working only once(initial render) #3715

vaishnavi-techp opened this issue Dec 5, 2024 · 21 comments · May be fixed by #3847
Labels
bug 🪲 Something isn't working

Comments

@vaishnavi-techp
Copy link

vaishnavi-techp commented Dec 5, 2024

Mapbox Implementation

Mapbox

Mapbox Version

10.1.32

React Native Version

0.74.5

Platform

Android

@rnmapbox/maps version

10.0.0-beta.32

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}}   onLongPress={() => console.log("long press")}>
        <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
        <ShapeSource id="idStreetLayer" shape={aLine}>
          <LineLayer id="idStreetLayer" />
        </ShapeSource>
      </MapView>
    );
  }
}

Observed behavior and steps to reproduce

onLongPress is triggered only once (during the initial render) on Android, but works as expected on iOS.

Expected behavior

onLongPress should be triggered whenever the user performs a long press on the map.

Notes / preliminary analysis

No response

Additional links and references

No response

@youtipie
Copy link

youtipie commented Dec 9, 2024

+1

@bitkraft-ssheikh
Copy link

I am facing the same issue.

@jayjo34
Copy link

jayjo34 commented Dec 19, 2024

Mee too

@prashantsail
Copy link

I am running into this issue as well. Is there a workaround available ?

@yashp1998
Copy link

I am facing same issue

@MykytaShchukin
Copy link

Also have this issue. Any solutions?

jessicagood added a commit to StraboSpot/StraboField that referenced this issue Jan 15, 2025
(Except @rnmapbox/maps as long press still an issue rnmapbox/maps#3715)
@smartmedev
Copy link

same issue for me. Any solutions??

@Pakile
Copy link

Pakile commented Feb 3, 2025

Also have this issue. Downgrade to version 10.1.31 to fix this issue

@cyburns
Copy link

cyburns commented Feb 3, 2025

+1

@txnnr
Copy link

txnnr commented Feb 6, 2025

I have this issue as well and downgrading to 10.1.31 did not solve the issue

@Pakile
Copy link

Pakile commented Feb 6, 2025

I have this issue as well and downgrading to 10.1.31 did not solve the issue

did you remove the ^?
fixed for me: "@rnmapbox/maps": "10.1.31",

@stalteri
Copy link

Same issue on 10.1.33. An older version (I don’t remember exactly which one) works well.

@mysport12
Copy link
Contributor

Seems like the issue was introduced when the android SDK version was bumped prior to 10.1.32 being released. Reverting the default sdk version via a fork/patch is a workaround while still using the latest release of rnmapbox

android/build.gradle:

  • def defaultMapboxMapsVersion = "10.18.4"
  • def defaultMapboxMapsVersion = "10.18.0"

gongdao123 added a commit to bartsolutions/maps that referenced this issue Feb 17, 2025
@vigor-13
Copy link

Same issue on 10.1.37

2 similar comments
@SsankQ
Copy link

SsankQ commented Mar 31, 2025

Same issue on 10.1.37

@ShahilMangroliya
Copy link
Contributor

Same issue on 10.1.37

@cyburns
Copy link

cyburns commented Apr 16, 2025

Any update on this issue?

@ShahilMangroliya
Copy link
Contributor

If you change def defaultMapboxMapsVersion = "10.18.0" in build.gradle of the this lib then its working

@vegtelenseg
Copy link

Not sure if this will work for others, but I had to use a newer version of mapbox.

[
  "@rnmapbox/maps",
  {
      "RNMapboxMapsVersion": "11.8.0"
  }
]

@deathook007
Copy link

Any workaround found here??

@dominikjambor
Copy link

@deathook007 Here's my complete workaround by locally patching the previously suggested version:

My rnmapbox version at the moment is: "@rnmapbox/maps": "10.1.37", (this is important for the patch definition)

  1. install patch-package npm i patch-package
  2. create the file patches/@rnmapbox+maps+10.1.37.patch with the following content:`
diff --git a/node_modules/@rnmapbox/maps/android/build.gradle b/node_modules/@rnmapbox/maps/android/build.gradle
index dd8e6c6..8f3ff59 100644
--- a/node_modules/@rnmapbox/maps/android/build.gradle
+++ b/node_modules/@rnmapbox/maps/android/build.gradle
@@ -1,5 +1,5 @@
 def defaultMapboxMapsImpl = "mapbox"
-def defaultMapboxMapsVersion = "10.18.4"
+def defaultMapboxMapsVersion = "10.18.3"
 
 def safeExtGet(prop, fallback) {
     rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
  1. run npx patch-package to patch the rnmapbox package.
  2. add the following script to package.json to make patch-package run in EAS builds: "eas-build-post-install": "patch-package"

Of course, this does not solve the problem, just downgrades the mapbox version to one that works, while keeping up with other fixes in this repo. At some point downgrading the version will break the library, but for now it works.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.