Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

addImage bug in v7.0.12 for android

Aperta
#118 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
android, typescript
Ambito
mobile-dev

Direzione di ricerca

Inizia da @nativescript-community/ui-mapbox/index.android.js, concentrandoti su addImage e sulla relativa chiamata a fetchImageSource. Confronta l’attuale API style-image di Mapbox Android SDK v11 con l’invocazione diretta di addImage e verifica il comportamento corretto rispetto al NoSuchMethodError segnalato. Il lavoro è completato quando è possibile aggiungere immagini su Android senza il crash dovuto alla firma.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hello, first thank you very much for upgrading the library. The nativescript community is amazing and very glad to see it constantly evolve and being maintained.

I think I found a bug. The contract changed slightly with mapbox sdk v11+ in Android for addImage as it seems its expecting to be wrapped by a ImageExtensionImpl builder before providing the image.

Therefore I was getting this error when trying to add an image in mapbox sdk

Error: java.lang.NoSuchMethodError: no static method "Lcom/mapbox/maps/MapboxStyleManager;.addImage(Ljava/lang/String;Landroid/graphics/Bitmap;)Lcom/mapbox/bindgen/Expected;

After debugging the problem I figured out reading the very clear documentation about the migration (this was a sarcasm of course)

I could not find any other reference that properly cast the image it seems like

style.addImage('id', imageBitMap)

should be supported but in my case it looks like the signature did not match thus crashed consistently.

So I got a proposition to fix this issue from reverse engeneering the implementation but I suspect this is not the proper way.

@nativescript-community/ui-mapbox/index.android.js

In addImage I changed :

const imageSource = await this.fetchImageSource(imagePath);
theMap.getStyle().addImage(imageId, imageSource.android);

To

const imageSource = await this.fetchImageSource(imagePath);
const bitmap = imageSource.android;

const ImageExtensionImpl = com.mapbox.maps.extension.style.image.ImageExtensionImpl;
const imageBuilder = new ImageExtensionImpl.Builder(imageId, bitmap);
const image = imageBuilder.build();

image.bindTo(theMap.getStyle());

resolve();

making sure that the bitmap is properly casted.

If anyone has a better solution or if I am totally mistaken let me know thank you.

Lingua principale
TypeScript
Stelle
38
Fork
26
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nativescript-community/ui-mapbox

Tutte le issue di nativescript-community/ui-mapbox

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.